Fix parse error for "s:()"

see #15
This commit is contained in:
Arne Keller 2021-07-19 11:12:58 +02:00
parent 5e6cb6ca4c
commit 08085ad44d
2 changed files with 15 additions and 1 deletions

View File

@ -331,7 +331,11 @@ public class TypeAssumptionParser {
ParserResult<Type> result = handleInnerParenthesis(
new Token(TokenType.EOF, "", "", -1));
if (result.isError()) {
return result.castError();
return result
// replace dummy EOF token
.modifyError(err ->
err.withToken(t, ParseError.ErrorType.TYPE_ASSUMPTION_ERROR))
.castError();
} else {
parsedType = Optional.of(result.getResult());
stateParenthesis = Optional.empty();

View File

@ -359,6 +359,16 @@ class TypeAssumptionParserTest {
e);
}
@Test
void errorCase4() {
ParseError e = parse("s:()");
assertEquals(ParseError
.unexpectedToken(new Token(Token.TokenType.RIGHT_PARENTHESIS, ")", "s:()", 3),
ParseError.ErrorType.TYPE_ASSUMPTION_ERROR)
.expectedInput(ExpectedInput.TYPE),
e);
}
static ParseError parse(String input) {
return new TypeAssumptionParser().parse(input).unwrapError();
}