Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Unbound namespaced record field error #259

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/refmterr/lib/parseError.re
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ let type_UnboundModule = (err, _, _) => {

/* need: if there's a hint, show which record type it is */
let type_UnboundRecordField = (err, _, _) => {
let recordFieldR = {|Unbound record field (\w+)|};
let recordFieldR = {|Unbound record field ([\w.]+)|};
get_match_maybe(recordFieldR, err)
|>? (
recordField => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Unformatted Error Output:
# File "tests/__tests__/refmterr/__fixtures__/file_SyntaxError/file_SyntaxError_7.re", line 20, characters 22-23:
# Error: Syntax error: ')' expected
# Error: Unclosed "{" (opened line 10, column 4)


 ERROR  tests/__tests__/refmterr/__fixtures__/file_SyntaxError/file_SyntaxError_7.re:20 22-23
Expand All @@ -11,26 +11,6 @@
20 ┆  ) : React.elem(tree);
21 ┆ };

This is a syntax error: ')' expected
Make sure all imperative statements, as well as let/type bindings have exactly one semicolon separating them.
Note: the location indicated might not be accurate.


# Unformatted Error Output:
# File "tests/__tests__/refmterr/__fixtures__/file_SyntaxError/file_SyntaxError_7.re", line 15, characters 43-44:
# Error: This '(' might be unmatched


 ERROR  tests/__tests__/refmterr/__fixtures__/file_SyntaxError/file_SyntaxError_7.re:15 43-44

12 ┆ type subtree = Dom.tree(React.empty);
13 ┆ type tree = state => subtree;
14 ┆ let createElement =
15 ┆  (~initialVal="deafult", children) => ((~state=initialVal, self) => (
16 ┆  state,
17 ┆  fun
18 ┆  | React.Changed(s) => s,



# Unformatted Error Output:
Expand All @@ -47,5 +27,5 @@ Note: the location indicated might not be accurate.



Command line: refmt 'tests/__tests__/refmterr/__fixtures__/file_SyntaxError/file_SyntaxError_7.re' > /tmp/ocamlpp2614dc
Command line: refmt 'tests/__tests__/refmterr/__fixtures__/file_SyntaxError/file_SyntaxError_7.re' > /tmp/ocamlpp2a48b2

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# File "tests/__tests__/refmterr/__fixtures__/type_IncompatibleType/type_IncompatibleType_1.ml", line 1, characters 3-6:
# Error: This expression has type int but an expression was expected of type
#  bool
#  because it is in the condition of an if-statement


 ERROR  tests/__tests__/refmterr/__fixtures__/type_IncompatibleType/type_IncompatibleType_1.ml:1 3-6
Expand All @@ -11,13 +10,8 @@

This type doesn't match what is expected.

This type:
int

Expecting:
ML: bool
Equals
 because it is in the condition of an if-statement
This type: int
Expecting: bool



Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let f (x : Complex.t) = x.Complex.z;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Unformatted Error Output:
# File "tests/__tests__/refmterr/__fixtures__/type_UnboundRecordField/type_UnboundRecordField_3.ml", line 1, characters 26-35:
# Error: Unbound record field Complex.z


 ERROR  tests/__tests__/refmterr/__fixtures__/type_UnboundRecordField/type_UnboundRecordField_3.ml:1 26-35

1 ┆ let f (x : Complex.t) = x.Complex.z;

Record field Complex.z can't be found in any record type.

Record fields must be "in scope". That means you need to `open TheModule` where the record type is defined.
Alternatively, instead of opening a module, you can prefix the record field name like {TheModule.x: 0, y: 100}.


2 changes: 1 addition & 1 deletion tests/__tests__/refmterr/refmterr_test.re
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let folders = [
("type_RecordFieldNotBelong", 3, [], []),
("type_RecordFieldsUndefined", 1, [], []),
("type_UnboundModule", 2, [], []),
("type_UnboundRecordField", 2, [], []),
("type_UnboundRecordField", 3, [], []),
("type_UnboundTypeConstructor", 2, [], []),
("type_UnboundValue", 4, [], []),
("type_FunctionWrongLabel", 5, [], []),
Expand Down