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

Commit 3aec2c8

Browse files
committed
Avoid parsing Eof during recovery for incomplete path.
See #542
1 parent eeaa86f commit 3aec2c8

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

src/res_core.ml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -710,21 +710,25 @@ let parseValuePath p =
710710
Longident.Ldot (path, "_")
711711
in
712712
let ident = match p.Parser.token with
713-
| Lident ident -> Longident.Lident ident
713+
| Lident ident ->
714+
Parser.next p;
715+
Longident.Lident ident
714716
| Uident ident ->
715717
Parser.next p;
716-
if p.Parser.token = Dot then (
718+
let res = if p.Parser.token = Dot then (
717719
Parser.expect Dot p;
718720
aux p (Lident ident)
719721
) else (
720722
Parser.err p (Diagnostics.unexpected p.Parser.token p.breadcrumbs);
721723
Longident.Lident ident
722-
)
724+
) in
725+
if p.token <> Eof then Parser.next p;
726+
res
723727
| token ->
724728
Parser.err p (Diagnostics.unexpected token p.breadcrumbs);
729+
Parser.next p;
725730
Longident.Lident "_"
726731
in
727-
Parser.next p;
728732
Location.mkloc ident (mkLoc startPos p.prevEndPos)
729733

730734
let parseValuePathAfterDot p =
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
Syntax error!
3+
tests/parsing/errors/expressions/id.res:1:5
4+
5+
1 │ n.R.
6+
7+
I'm not sure what to parse here when looking at "eof".
8+
9+
;;n.R._
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
n.R.

0 commit comments

Comments
 (0)