Skip to content

Commit 544c1e3

Browse files
authored
Merge pull request #4470 from yawaramin/patch-1
Tweak error message for not found record fields/constructors
2 parents 982cfee + e771ce5 commit 544c1e3

File tree

4 files changed

+32
-16
lines changed

4 files changed

+32
-16
lines changed

jscomp/super_errors/super_typetexp.ml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,25 @@ let report_error env ppf = function
109109
fprintf ppf "@[<v>\
110110
@{<info>The variant constructor %a can't be found.@}@,@,\
111111
@[<v 2>- If it's defined in another module or file, bring it into scope by:@,\
112-
@[- Annotating it with said module name:@ @{<info>let food = MyModule.Apple@}@]@,\
113-
@[- Or specifying its type:@ @{<info>let food: MyModule.fruit = Apple@}@]\
112+
@[- Prefixing it with said module name:@ @{<info>TheModule.%a@}@]@,\
113+
@[- Or specifying its type:@ @{<info>let theValue: TheModule.theType = %a@}@]\
114114
@]@,\
115115
- @[Constructors and modules are both capitalized.@ Did you want the latter?@ Then instead of @{<dim>let foo = Bar@}, try @{<info>module Foo = Bar@}.@]\
116116
@]"
117+
longident lid
118+
longident lid
117119
longident lid;
118120
Typetexp.spellcheck ppf fold_constructors env lid
119121
| Unbound_label lid ->
120122
(* modified *)
121123
fprintf ppf "@[<v>\
122124
@{<info>The record field %a can't be found.@}@,@,\
123125
If it's defined in another module or file, bring it into scope by:@,\
124-
@[- Annotating it with said module name:@ @{<info>let baby = {MyModule.age: 3}@}@]@,\
125-
@[- Or specifying its type:@ @{<info>let baby: MyModule.person = {age: 3}@}@]\
126+
@[- Prefixing it with said module name:@ @{<info>TheModule.%a@}@]@,\
127+
@[- Or specifying its type:@ @{<info>let theValue: TheModule.theType = {%a: VALUE}@}@]\
126128
@]"
129+
longident lid
130+
longident lid
127131
longident lid;
128132
Typetexp.spellcheck ppf fold_labels env lid
129133
| anythingElse ->

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411785,21 +411785,25 @@ let report_error env ppf = function
411785411785
fprintf ppf "@[<v>\
411786411786
@{<info>The variant constructor %a can't be found.@}@,@,\
411787411787
@[<v 2>- If it's defined in another module or file, bring it into scope by:@,\
411788-
@[- Annotating it with said module name:@ @{<info>let food = MyModule.Apple@}@]@,\
411789-
@[- Or specifying its type:@ @{<info>let food: MyModule.fruit = Apple@}@]\
411788+
@[- Prefixing it with said module name:@ @{<info>TheModule.%a@}@]@,\
411789+
@[- Or specifying its type:@ @{<info>let theValue: TheModule.theType = %a@}@]\
411790411790
@]@,\
411791411791
- @[Constructors and modules are both capitalized.@ Did you want the latter?@ Then instead of @{<dim>let foo = Bar@}, try @{<info>module Foo = Bar@}.@]\
411792411792
@]"
411793+
longident lid
411794+
longident lid
411793411795
longident lid;
411794411796
Typetexp.spellcheck ppf fold_constructors env lid
411795411797
| Unbound_label lid ->
411796411798
(* modified *)
411797411799
fprintf ppf "@[<v>\
411798411800
@{<info>The record field %a can't be found.@}@,@,\
411799411801
If it's defined in another module or file, bring it into scope by:@,\
411800-
@[- Annotating it with said module name:@ @{<info>let baby = {MyModule.age: 3}@}@]@,\
411801-
@[- Or specifying its type:@ @{<info>let baby: MyModule.person = {age: 3}@}@]\
411802+
@[- Prefixing it with said module name:@ @{<info>TheModule.%a@}@]@,\
411803+
@[- Or specifying its type:@ @{<info>let theValue: TheModule.theType = {%a: VALUE}@}@]\
411802411804
@]"
411805+
longident lid
411806+
longident lid
411803411807
longident lid;
411804411808
Typetexp.spellcheck ppf fold_labels env lid
411805411809
| anythingElse ->

lib/4.06.1/unstable/js_refmt_compiler.ml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571881,21 +571881,25 @@ let report_error env ppf = function
571881571881
fprintf ppf "@[<v>\
571882571882
@{<info>The variant constructor %a can't be found.@}@,@,\
571883571883
@[<v 2>- If it's defined in another module or file, bring it into scope by:@,\
571884-
@[- Annotating it with said module name:@ @{<info>let food = MyModule.Apple@}@]@,\
571885-
@[- Or specifying its type:@ @{<info>let food: MyModule.fruit = Apple@}@]\
571884+
@[- Prefixing it with said module name:@ @{<info>TheModule.%a@}@]@,\
571885+
@[- Or specifying its type:@ @{<info>let theValue: TheModule.theType = %a@}@]\
571886571886
@]@,\
571887571887
- @[Constructors and modules are both capitalized.@ Did you want the latter?@ Then instead of @{<dim>let foo = Bar@}, try @{<info>module Foo = Bar@}.@]\
571888571888
@]"
571889+
longident lid
571890+
longident lid
571889571891
longident lid;
571890571892
Typetexp.spellcheck ppf fold_constructors env lid
571891571893
| Unbound_label lid ->
571892571894
(* modified *)
571893571895
fprintf ppf "@[<v>\
571894571896
@{<info>The record field %a can't be found.@}@,@,\
571895571897
If it's defined in another module or file, bring it into scope by:@,\
571896-
@[- Annotating it with said module name:@ @{<info>let baby = {MyModule.age: 3}@}@]@,\
571897-
@[- Or specifying its type:@ @{<info>let baby: MyModule.person = {age: 3}@}@]\
571898+
@[- Prefixing it with said module name:@ @{<info>TheModule.%a@}@]@,\
571899+
@[- Or specifying its type:@ @{<info>let theValue: TheModule.theType = {%a: VALUE}@}@]\
571898571900
@]"
571901+
longident lid
571902+
longident lid
571899571903
longident lid;
571900571904
Typetexp.spellcheck ppf fold_labels env lid
571901571905
| anythingElse ->

lib/4.06.1/whole_compiler.ml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418845,21 +418845,25 @@ let report_error env ppf = function
418845418845
fprintf ppf "@[<v>\
418846418846
@{<info>The variant constructor %a can't be found.@}@,@,\
418847418847
@[<v 2>- If it's defined in another module or file, bring it into scope by:@,\
418848-
@[- Annotating it with said module name:@ @{<info>let food = MyModule.Apple@}@]@,\
418849-
@[- Or specifying its type:@ @{<info>let food: MyModule.fruit = Apple@}@]\
418848+
@[- Prefixing it with said module name:@ @{<info>TheModule.%a@}@]@,\
418849+
@[- Or specifying its type:@ @{<info>let theValue: TheModule.theType = %a@}@]\
418850418850
@]@,\
418851418851
- @[Constructors and modules are both capitalized.@ Did you want the latter?@ Then instead of @{<dim>let foo = Bar@}, try @{<info>module Foo = Bar@}.@]\
418852418852
@]"
418853+
longident lid
418854+
longident lid
418853418855
longident lid;
418854418856
Typetexp.spellcheck ppf fold_constructors env lid
418855418857
| Unbound_label lid ->
418856418858
(* modified *)
418857418859
fprintf ppf "@[<v>\
418858418860
@{<info>The record field %a can't be found.@}@,@,\
418859418861
If it's defined in another module or file, bring it into scope by:@,\
418860-
@[- Annotating it with said module name:@ @{<info>let baby = {MyModule.age: 3}@}@]@,\
418861-
@[- Or specifying its type:@ @{<info>let baby: MyModule.person = {age: 3}@}@]\
418862+
@[- Prefixing it with said module name:@ @{<info>TheModule.%a@}@]@,\
418863+
@[- Or specifying its type:@ @{<info>let theValue: TheModule.theType = {%a: VALUE}@}@]\
418862418864
@]"
418865+
longident lid
418866+
longident lid
418863418867
longident lid;
418864418868
Typetexp.spellcheck ppf fold_labels env lid
418865418869
| anythingElse ->

0 commit comments

Comments
 (0)