fix: do not create choice nodes for failed parses
This commit is contained in:
parent
57320712f0
commit
246923886a
3 changed files with 6 additions and 2 deletions
|
|
@ -1389,8 +1389,7 @@ def keepPrevError (s : ParserState) (oldStackSize : Nat) (oldStopPos : String.Po
|
|||
def mergeErrors (s : ParserState) (oldStackSize : Nat) (oldError : Error) : ParserState :=
|
||||
match s with
|
||||
| ⟨stack, lhsPrec, pos, cache, some err⟩ =>
|
||||
if oldError == err then s
|
||||
else ⟨stack.shrink oldStackSize, lhsPrec, pos, cache, some (oldError.merge err)⟩
|
||||
⟨stack.shrink oldStackSize, lhsPrec, pos, cache, if oldError == err then some err else some (oldError.merge err)⟩
|
||||
| other => other
|
||||
|
||||
def keepLatest (s : ParserState) (startStackSize : Nat) : ParserState :=
|
||||
|
|
|
|||
3
tests/lean/1760.lean
Normal file
3
tests/lean/1760.lean
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
-- should run in linear time
|
||||
#check [[[[[[[[[[[[[[[[[[[[[[[[
|
||||
#check (((((((((((((((((((((((())))))))))))))))))))))))
|
||||
2
tests/lean/1760.lean.expected.out
Normal file
2
tests/lean/1760.lean.expected.out
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
1760.lean:3:0: error: expected ':', ']' or term
|
||||
() : Unit
|
||||
Loading…
Add table
Reference in a new issue