diff --git a/jscomp/build_tests/super_errors/expected/unbound_record_field.res.expected b/jscomp/build_tests/super_errors/expected/unbound_record_field.res.expected new file mode 100644 index 0000000000..29ea442502 --- /dev/null +++ b/jscomp/build_tests/super_errors/expected/unbound_record_field.res.expected @@ -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 no corresponding record type is in scope. + + If it's defined in another module or file, bring it into scope by: + - Prefixing the field name with the module name: TheModule.someUnknownField + - Or specifying the record type explicitly: + let theValue: TheModule.theType = {someUnknownField: VALUE} \ No newline at end of file diff --git a/jscomp/build_tests/super_errors/fixtures/unbound_record_field.res b/jscomp/build_tests/super_errors/fixtures/unbound_record_field.res new file mode 100644 index 0000000000..074704bff1 --- /dev/null +++ b/jscomp/build_tests/super_errors/fixtures/unbound_record_field.res @@ -0,0 +1,4 @@ +let foo = x => + switch x { + | {someUnknownField: 123} => () + } diff --git a/jscomp/ml/typetexp.ml b/jscomp/ml/typetexp.ml index def4427a3b..aa8cdf6d5d 100644 --- a/jscomp/ml/typetexp.ml +++ b/jscomp/ml/typetexp.ml @@ -910,10 +910,10 @@ let report_error env ppf = function | Unbound_label lid -> (* modified *) Format.fprintf ppf "@[\ - @{The record field %a can't be found.@}@,@,\ + @{%a@} refers to a record field, but no corresponding record type is in scope.@,@,\ If it's defined in another module or file, bring it into scope by:@,\ - @[- Prefixing it with said module name:@ @{TheModule.%a@}@]@,\ - @[- Or specifying its type:@ @{let theValue: TheModule.theType = {%a: VALUE}@}@]\ + @[- Prefixing the field name with the module name:@ @{TheModule.%a@}@]@,\ + @[- Or specifying the record type explicitly:@ @{let theValue: TheModule.theType = {%a: VALUE}@}@]\ @]" Printtyp.longident lid Printtyp.longident lid