diff --git a/src/main/java/edu/kit/typicalc/model/parser/TypeAssumptionParser.java b/src/main/java/edu/kit/typicalc/model/parser/TypeAssumptionParser.java index 92d52e6..33cb5d2 100644 --- a/src/main/java/edu/kit/typicalc/model/parser/TypeAssumptionParser.java +++ b/src/main/java/edu/kit/typicalc/model/parser/TypeAssumptionParser.java @@ -331,7 +331,11 @@ public class TypeAssumptionParser { ParserResult 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(); diff --git a/src/test/java/edu/kit/typicalc/model/parser/TypeAssumptionParserTest.java b/src/test/java/edu/kit/typicalc/model/parser/TypeAssumptionParserTest.java index ac6d6ca..74243a5 100644 --- a/src/test/java/edu/kit/typicalc/model/parser/TypeAssumptionParserTest.java +++ b/src/test/java/edu/kit/typicalc/model/parser/TypeAssumptionParserTest.java @@ -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(); }