mirror of
https://github.com/apple/pkl.git
synced 2026-06-05 21:32:45 +02:00
Improve error message when parsing truncated let expressions (#1639)
This previously yielded ``` Unexpected token `}`. Expected `}`. ``` Pretty confusing, no? Now it's just ``` Unexpected token `}`. ``` Resolves #1638
This commit is contained in:
@@ -888,7 +888,7 @@ class GenericParserImpl {
|
||||
expect(Token.RPAREN, paramDef, "unexpectedToken", ")");
|
||||
children.add(new Node(NodeType.LET_PARAMETER_DEFINITION, paramDef));
|
||||
ff(children);
|
||||
children.add(parseExpr(expectation));
|
||||
children.add(parseExpr());
|
||||
yield new Node(NodeType.LET_EXPR, children);
|
||||
}
|
||||
case TRUE, FALSE -> new Node(NodeType.BOOL_LITERAL_EXPR, next().span);
|
||||
|
||||
@@ -1009,7 +1009,7 @@ final class ParserImpl {
|
||||
expect(Token.ASSIGN, "unexpectedToken", "=");
|
||||
var bindExpr = parseExpr(")");
|
||||
expect(Token.RPAREN, "unexpectedToken", ")");
|
||||
var exp = parseExpr(expectation);
|
||||
var exp = parseExpr();
|
||||
yield new LetExpr(param, bindExpr, exp, start.endWith(exp.span()));
|
||||
}
|
||||
case TRUE -> new BoolLiteralExpr(true, next().span);
|
||||
|
||||
@@ -99,6 +99,7 @@ class ParserComparisonTest {
|
||||
"errors/invalidCharacterEscape.pkl",
|
||||
"errors/invalidCharacterEscape2.pkl",
|
||||
"errors/invalidUnicodeEscape.pkl",
|
||||
"errors/letExpressionError3.pkl",
|
||||
"errors/unterminatedUnicodeEscape.pkl",
|
||||
"errors/keywordNotAllowedHere1.pkl",
|
||||
"errors/keywordNotAllowedHere2.pkl",
|
||||
|
||||
Reference in New Issue
Block a user