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

Commit 2187928

Browse files
Merge pull request #17 from BuckleScript/FixGh16
Close binary expressions parsing correct
2 parents b3aa1db + ad56165 commit 2187928

File tree

4 files changed

+93
-0
lines changed

4 files changed

+93
-0
lines changed

src/napkin_core.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2068,6 +2068,7 @@ and parseBinaryExpr ?(context=OrdinaryExpr) ?a p prec =
20682068
(makeInfixOperator p token startPos endPos)
20692069
[Nolabel, a; Nolabel, b]
20702070
in
2071+
Parser.eatBreadcrumb p;
20712072
loop expr
20722073
end
20732074
in

tests/parsing/errors/structure/__snapshots__/parse.spec.js.snap

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,70 @@ consecutive statements on a line must be separated by ';' or a newline
3737
3838
3939
40+
========================================================"
41+
`;
42+
43+
exports[`gh16A.ns 1`] = `
44+
"=====Parsetree==========================================
45+
module C = struct module T = (Fun)(struct ;;foo (a + c) (b + d) end) end
46+
;;Js.log \\"test\\"
47+
=====Errors=============================================
48+
49+
File \\"/syntax/tests/parsing/errors/structure/gh16A.ns\\", line 6, characters 0-1:
50+
51+
52+
4 │ })
53+
5 │ }
54+
6 │ )
55+
7 │ Js.log(\\"test\\"); // Is omitted from the compiled JS
56+
57+
I'm not sure what to parse here when looking at \\")\\".
58+
59+
60+
61+
========================================================"
62+
`;
63+
64+
exports[`gh16B.ns 1`] = `
65+
"=====Parsetree==========================================
66+
open Ws
67+
let wss = Server.make { port = 82 }
68+
let address = wss |. Server.address
69+
let log msg = Js.log ({|> Server: |} ^ msg)
70+
;;log
71+
(((((({|Running on: |} ^ address.address) ^ {|:|}) ^
72+
(address.port |. string_of_int))
73+
^ {| (|})
74+
^ address.family)
75+
^ {|)|})
76+
module ClientSet =
77+
struct
78+
module T =
79+
(Belt.Id.MakeComparable)(struct
80+
type nonrec t = Client.t
81+
let cmp a b =
82+
((compare (a |. Client.getUniqueId)
83+
(b |. Client.getUniqueId))
84+
[@ns.braces ])
85+
end)
86+
let empty = Belt.Set.make ~id:(((module T))[@ns.namedArgLoc ])
87+
end
88+
;;Js.log \\"test\\"
89+
=====Errors=============================================
90+
91+
File \\"/syntax/tests/parsing/errors/structure/gh16B.ns\\", line 19, characters 1-2:
92+
93+
94+
17
95+
18
96+
19 │ })))))))))))))))))))))))))))))); // this \\")\\" here, this can even be \\"))))))))))))))))\\" and should error
97+
20
98+
21Js.log(\\"test\\") // should not be omitted
99+
100+
I'm not sure what to parse here when looking at \\")\\".
101+
102+
103+
40104
========================================================"
41105
`;
42106
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module C = {
2+
module T = Fun({
3+
foo(a + c, b + d)
4+
})
5+
}
6+
)
7+
Js.log("test"); // Is omitted from the compiled JS
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
open Ws
2+
3+
let wss = Server.make({port: 82})
4+
let address = wss->Server.address
5+
let log = msg => Js.log(`> Server: ${msg}`)
6+
log(`Running on: ${address.address}:${address.port->string_of_int} (${address.family})`)
7+
8+
module ClientSet = {
9+
module T = Belt.Id.MakeComparable({
10+
type t = Client.t;
11+
let cmp = (a, b) => {
12+
compare(a->Client.getUniqueId, b->Client.getUniqueId);
13+
};
14+
});
15+
16+
let empty = Belt.Set.make(~id=module (T));
17+
18+
19+
})))))))))))))))))))))))))))))); // this ")" here, this can even be "))))))))))))))))" and should error
20+
21+
Js.log("test") // should not be omitted

0 commit comments

Comments
 (0)