Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Close binary expressions parsing correct #17

Merged
merged 1 commit into from
Jul 5, 2020
Merged
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
1 change: 1 addition & 0 deletions src/napkin_core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2068,6 +2068,7 @@ and parseBinaryExpr ?(context=OrdinaryExpr) ?a p prec =
(makeInfixOperator p token startPos endPos)
[Nolabel, a; Nolabel, b]
in
Parser.eatBreadcrumb p;
loop expr
end
in
Expand Down
64 changes: 64 additions & 0 deletions tests/parsing/errors/structure/__snapshots__/parse.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,70 @@ consecutive statements on a line must be separated by ';' or a newline



========================================================"
`;

exports[`gh16A.ns 1`] = `
"=====Parsetree==========================================
module C = struct module T = (Fun)(struct ;;foo (a + c) (b + d) end) end
;;Js.log \\"test\\"
=====Errors=============================================

File \\"/syntax/tests/parsing/errors/structure/gh16A.ns\\", line 6, characters 0-1:


4 │ })
5 │ }
6 │ )
7 │ Js.log(\\"test\\"); // Is omitted from the compiled JS

I'm not sure what to parse here when looking at \\")\\".



========================================================"
`;

exports[`gh16B.ns 1`] = `
"=====Parsetree==========================================
open Ws
let wss = Server.make { port = 82 }
let address = wss |. Server.address
let log msg = Js.log ({|> Server: |} ^ msg)
;;log
(((((({|Running on: |} ^ address.address) ^ {|:|}) ^
(address.port |. string_of_int))
^ {| (|})
^ address.family)
^ {|)|})
module ClientSet =
struct
module T =
(Belt.Id.MakeComparable)(struct
type nonrec t = Client.t
let cmp a b =
((compare (a |. Client.getUniqueId)
(b |. Client.getUniqueId))
[@ns.braces ])
end)
let empty = Belt.Set.make ~id:(((module T))[@ns.namedArgLoc ])
end
;;Js.log \\"test\\"
=====Errors=============================================

File \\"/syntax/tests/parsing/errors/structure/gh16B.ns\\", line 19, characters 1-2:


17 │
18 │
19 │ })))))))))))))))))))))))))))))); // this \\")\\" here, this can even be \\"))))))))))))))))\\" and should error
20 │
21 │ Js.log(\\"test\\") // should not be omitted

I'm not sure what to parse here when looking at \\")\\".



========================================================"
`;

Expand Down
7 changes: 7 additions & 0 deletions tests/parsing/errors/structure/gh16A.ns
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module C = {
module T = Fun({
foo(a + c, b + d)
})
}
)
Js.log("test"); // Is omitted from the compiled JS
21 changes: 21 additions & 0 deletions tests/parsing/errors/structure/gh16B.ns
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
open Ws

let wss = Server.make({port: 82})
let address = wss->Server.address
let log = msg => Js.log(`> Server: ${msg}`)
log(`Running on: ${address.address}:${address.port->string_of_int} (${address.family})`)

module ClientSet = {
module T = Belt.Id.MakeComparable({
type t = Client.t;
let cmp = (a, b) => {
compare(a->Client.getUniqueId, b->Client.getUniqueId);
};
});

let empty = Belt.Set.make(~id=module (T));


})))))))))))))))))))))))))))))); // this ")" here, this can even be "))))))))))))))))" and should error

Js.log("test") // should not be omitted