From bd741d070db2ba5bb3ad40008647d315b4eafafc Mon Sep 17 00:00:00 2001 From: Remi Date: Tue, 29 Sep 2020 23:40:23 +0200 Subject: [PATCH 1/3] fix(parseError): unbound namespaced record field error --- src/refmterr/lib/parseError.re | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/refmterr/lib/parseError.re b/src/refmterr/lib/parseError.re index 7ce127f4..dc6b9458 100644 --- a/src/refmterr/lib/parseError.re +++ b/src/refmterr/lib/parseError.re @@ -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 => { From 3de4d1fadcf0d9d5b5132003f1e8fceed7959a92 Mon Sep 17 00:00:00 2001 From: Remi Date: Tue, 29 Sep 2020 23:40:36 +0200 Subject: [PATCH 2/3] test(parseError): unbound namespaced record field error --- .../type_UnboundRecordField_3.ml | 1 + .../type_UnboundRecordField_3_expected.txt | 15 +++++++++++++++ tests/__tests__/refmterr/refmterr_test.re | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100755 tests/__tests__/refmterr/__fixtures__/type_UnboundRecordField/type_UnboundRecordField_3.ml create mode 100644 tests/__tests__/refmterr/__fixtures__/type_UnboundRecordField/type_UnboundRecordField_3_expected.txt diff --git a/tests/__tests__/refmterr/__fixtures__/type_UnboundRecordField/type_UnboundRecordField_3.ml b/tests/__tests__/refmterr/__fixtures__/type_UnboundRecordField/type_UnboundRecordField_3.ml new file mode 100755 index 00000000..ff74583d --- /dev/null +++ b/tests/__tests__/refmterr/__fixtures__/type_UnboundRecordField/type_UnboundRecordField_3.ml @@ -0,0 +1 @@ +let f (x : Complex.t) = x.Complex.z; \ No newline at end of file diff --git a/tests/__tests__/refmterr/__fixtures__/type_UnboundRecordField/type_UnboundRecordField_3_expected.txt b/tests/__tests__/refmterr/__fixtures__/type_UnboundRecordField/type_UnboundRecordField_3_expected.txt new file mode 100644 index 00000000..b8d131ff --- /dev/null +++ b/tests/__tests__/refmterr/__fixtures__/type_UnboundRecordField/type_UnboundRecordField_3_expected.txt @@ -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}. + + diff --git a/tests/__tests__/refmterr/refmterr_test.re b/tests/__tests__/refmterr/refmterr_test.re index 12fd4020..1f15580f 100644 --- a/tests/__tests__/refmterr/refmterr_test.re +++ b/tests/__tests__/refmterr/refmterr_test.re @@ -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, [], []), From 7fb88ae16fdb7c5b06f1aedb8a3880545605047c Mon Sep 17 00:00:00 2001 From: Remi Date: Wed, 30 Sep 2020 12:08:08 +0200 Subject: [PATCH 3/3] test(refmterr): fix failing tests --- .../file_SyntaxError_7_expected.txt | 24 ++----------------- .../type_IncompatibleType_1_expected.txt | 10 ++------ 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/tests/__tests__/refmterr/__fixtures__/file_SyntaxError/file_SyntaxError_7_expected.txt b/tests/__tests__/refmterr/__fixtures__/file_SyntaxError/file_SyntaxError_7_expected.txt index 4b9a61c1..e73d6983 100644 --- a/tests/__tests__/refmterr/__fixtures__/file_SyntaxError/file_SyntaxError_7_expected.txt +++ b/tests/__tests__/refmterr/__fixtures__/file_SyntaxError/file_SyntaxError_7_expected.txt @@ -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 @@ -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: @@ -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 diff --git a/tests/__tests__/refmterr/__fixtures__/type_IncompatibleType/type_IncompatibleType_1_expected.txt b/tests/__tests__/refmterr/__fixtures__/type_IncompatibleType/type_IncompatibleType_1_expected.txt index ba69c3da..759767cd 100644 --- a/tests/__tests__/refmterr/__fixtures__/type_IncompatibleType/type_IncompatibleType_1_expected.txt +++ b/tests/__tests__/refmterr/__fixtures__/type_IncompatibleType/type_IncompatibleType_1_expected.txt @@ -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 @@ -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