Skip to content

Commit

Permalink
fix: do not create choice nodes for failed parses
Browse files Browse the repository at this point in the history
  • Loading branch information
Kha committed Nov 4, 2022
1 parent 9850e7a commit ec8b114
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/Lean/Parser/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1381,8 +1381,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 :=
Expand Down
3 changes: 3 additions & 0 deletions tests/lean/1760.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- should run in linear time
#check [[[[[[[[[[[[[[[[[[[[[[[[
#check (((((((((((((((((((((((())))))))))))))))))))))))

0 comments on commit ec8b114

Please sign in to comment.