fix: remove negative number literal parsing in lexer and update tests for unary minus precedence
The lexer previously treated a leading minus sign followed by a digit as a single negative number token, which caused incorrect parsing of expressions like `1-1` and broke method calls on negative numbers. This change removes that special case, making the minus sign always a separate token, and updates all test expectations to use explicit parentheses for negative number method calls.
This commit is contained in:
+1
-8
@@ -752,14 +752,7 @@ static void nextToken(Parser* parser)
|
||||
return;
|
||||
|
||||
case '-':
|
||||
if (isDigit(peekChar(parser)))
|
||||
{
|
||||
readNumber(parser);
|
||||
}
|
||||
else
|
||||
{
|
||||
makeToken(parser, TOKEN_MINUS);
|
||||
}
|
||||
makeToken(parser, TOKEN_MINUS);
|
||||
return;
|
||||
|
||||
case '|':
|
||||
|
||||
Reference in New Issue
Block a user