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

Commit d153447

Browse files
author
Iwan
committed
Annotate jsx regions with the correct breadcrumbs.
Results in the correct errors being reported after the jsx. Fixes #120
1 parent f6a714f commit d153447

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

src/res_core.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2520,6 +2520,7 @@ and parseJsx p =
25202520
| _ ->
25212521
parseJsxName p
25222522
in
2523+
Parser.eatBreadcrumb p;
25232524
{jsxExpr with pexp_attributes = [jsxAttr]}
25242525

25252526
(*
@@ -2547,7 +2548,6 @@ and parseJsxFragment p =
25472548
* | lident = ?jsx_expr
25482549
*)
25492550
and parseJsxProp p =
2550-
Parser.leaveBreadcrumb p Grammar.JsxAttribute;
25512551
match p.Parser.token with
25522552
| Question | Lident _ ->
25532553
let optional = Parser.optional p Question in

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,30 @@ switch result {
300300
301301
302302
303+
========================================================"
304+
`;
305+
306+
exports[`implementation.res 1`] = `
307+
"=====Parsetree==========================================
308+
module InstallerDownload =
309+
struct
310+
let make () = ((div ~children:[] ())[@ns.braces ][@JSX ])[@@react.component
311+
]
312+
end
313+
module LicenseList = struct end
314+
=====Errors=============================================
315+
316+
Syntax error!
317+
parsing/errors/expressions/implementation.res 7:1
318+
5 │ }
319+
6 │ }
320+
7 │ }
321+
8 │ module LicenseList = {
322+
9
323+
324+
I'm not sure what to parse here when looking at \\"}\\".
325+
326+
303327
========================================================"
304328
`;
305329
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module InstallerDownload = {
2+
@react.component
3+
let make = () => {
4+
<div />
5+
}
6+
}
7+
}
8+
module LicenseList = {
9+
10+
}

0 commit comments

Comments
 (0)