Fix infinite loop when parsing parameter list
This fixes a bug reported by David Garrison: on encountering the new function argument validation syntax, the parser went into an infinite loop.
This commit is contained in:
parent
6c204846ce
commit
98ae1a1499
@ -1,5 +1,6 @@
|
||||
using Xunit;
|
||||
using FluentAssertions;
|
||||
using System;
|
||||
|
||||
namespace Parser.Tests
|
||||
{
|
||||
@ -150,5 +151,34 @@ namespace Parser.Tests
|
||||
rhs.Span.Start.Should().Be(16);
|
||||
rhs.Span.End.Should().Be(17);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NotHangOnUnknownSyntax()
|
||||
{
|
||||
var text = @"
|
||||
classdef myClass
|
||||
properties
|
||||
Channel;
|
||||
NodeID;
|
||||
Node;
|
||||
end
|
||||
methods
|
||||
function this = sendData(this, arg1, arg2)
|
||||
arguments
|
||||
this (1,1) myClass
|
||||
arg1 (1,1) double {mustBeNonnegative}
|
||||
arg2 (1,1) double {mustBeNonnegative}
|
||||
end
|
||||
If (arg1 = 0)
|
||||
this.NodeID = 3;
|
||||
end
|
||||
end
|
||||
function this = getData(this, arg1, arg2)
|
||||
end
|
||||
end";
|
||||
var sut = GetSut(text);
|
||||
Func<SyntaxTree> action = sut.Parse;
|
||||
action.Should().Throw<ParsingException>();
|
||||
}
|
||||
}
|
||||
}
|
@ -170,6 +170,10 @@ namespace Parser.Internal
|
||||
{
|
||||
var identifierToken = EatToken(TokenKind.IdentifierToken);
|
||||
builder.Add(Factory.IdentifierNameExpressionSyntax(identifierToken));
|
||||
if (identifierToken.IsMissing)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user