Skip to content

Commit beb79ef

Browse files
authored
Tweak unbound record field error message (#7064)
* tweak unbound record field error message * update message
1 parent c2005fd commit beb79ef

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
We've found a bug for you!
3+
/.../fixtures/unbound_record_field.res:3:6-21
4+
5+
1 │ let foo = x =>
6+
2 │ switch x {
7+
3 │ | {someUnknownField: 123} => ()
8+
4 │ }
9+
5 │
10+
11+
someUnknownField refers to a record field, but no corresponding record type is in scope.
12+
13+
If it's defined in another module or file, bring it into scope by:
14+
- Prefixing the field name with the module name: TheModule.someUnknownField
15+
- Or specifying the record type explicitly:
16+
let theValue: TheModule.theType = {someUnknownField: VALUE}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
let foo = x =>
2+
switch x {
3+
| {someUnknownField: 123} => ()
4+
}

jscomp/ml/typetexp.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -910,10 +910,10 @@ let report_error env ppf = function
910910
| Unbound_label lid ->
911911
(* modified *)
912912
Format.fprintf ppf "@[<v>\
913-
@{<info>The record field %a can't be found.@}@,@,\
913+
@{<info>%a@} refers to a record field, but no corresponding record type is in scope.@,@,\
914914
If it's defined in another module or file, bring it into scope by:@,\
915-
@[- Prefixing it with said module name:@ @{<info>TheModule.%a@}@]@,\
916-
@[- Or specifying its type:@ @{<info>let theValue: TheModule.theType = {%a: VALUE}@}@]\
915+
@[- Prefixing the field name with the module name:@ @{<info>TheModule.%a@}@]@,\
916+
@[- Or specifying the record type explicitly:@ @{<info>let theValue: TheModule.theType = {%a: VALUE}@}@]\
917917
@]"
918918
Printtyp.longident lid
919919
Printtyp.longident lid

0 commit comments

Comments
 (0)