Fix crash in parser

The Until parse node would return True if it reached EOF, which was not
correct and could cause other parse nodes to run past the end of the
token list and crash.
This commit is contained in:
James Westman 2022-04-18 17:05:07 -05:00
parent 417f163a5a
commit e76bff9291
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6

View file

@ -371,6 +371,9 @@ class Until(ParseNode):
def _parse(self, ctx): def _parse(self, ctx):
while not self.delimiter.parse(ctx).succeeded(): while not self.delimiter.parse(ctx).succeeded():
if ctx.is_eof():
return False
try: try:
if not self.child.parse(ctx).matched(): if not self.child.parse(ctx).matched():
ctx.skip_unexpected_token() ctx.skip_unexpected_token()
@ -378,9 +381,6 @@ class Until(ParseNode):
ctx.errors.append(e) ctx.errors.append(e)
ctx.next_token() ctx.next_token()
if ctx.is_eof():
return True
return True return True