Skip to content

Commit

Permalink
tweak unbound record field error message
Browse files Browse the repository at this point in the history
  • Loading branch information
zth committed Oct 1, 2024
1 parent ac30044 commit bb22c45
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

We've found a bug for you!
/.../fixtures/unbound_record_field.res:3:6-21

1 │ let foo = x =>
2 │ switch x {
3 │ | {someUnknownField: 123} => ()
4 │ }
5 │

someUnknownField refers to a record field, but the record type it belongs to couldn't be found automatically.

If it's defined in another module or file, bring it into scope by:
- Prefixing it with said module name: TheModule.someUnknownField
- Or specifying its type:
let theValue: TheModule.theType = {someUnknownField: VALUE}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
let foo = x =>
switch x {
| {someUnknownField: 123} => ()
}
2 changes: 1 addition & 1 deletion jscomp/ml/typetexp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ let report_error env ppf = function
| Unbound_label lid ->
(* modified *)
Format.fprintf ppf "@[<v>\
@{<info>The record field %a can't be found.@}@,@,\
@{<info>%a@} refers to a record field, but the record type it belongs to couldn't be found automatically.@,@,\
If it's defined in another module or file, bring it into scope by:@,\
@[- Prefixing it with said module name:@ @{<info>TheModule.%a@}@]@,\
@[- Or specifying its type:@ @{<info>let theValue: TheModule.theType = {%a: VALUE}@}@]\
Expand Down

0 comments on commit bb22c45

Please sign in to comment.