Found a rare lexer bug

This commit is contained in:
2022-09-10 19:11:16 +01:00
parent 60ddd151a6
commit cbc937884e
2 changed files with 6 additions and 1 deletions

View File

@@ -139,7 +139,7 @@ static Token makeIntegerOrFloat(Lexer* lexer) {
while(isDigit(lexer)) advance(lexer);
if (peek(lexer) == '.') {
if (peek(lexer) == '.' && (peekNext(lexer) >= '0' && peekNext(lexer) <= '9')) { //BUGFIX: peekNext == digit
type = TOKEN_LITERAL_FLOAT;
advance(lexer);
while(isDigit(lexer)) advance(lexer);

View File

@@ -791,6 +791,11 @@ static Opcode dot(Parser* parser, Node** nodeHandle) {
parsePrecedence(parser, &node, PREC_CALL);
if (node == NULL || node->binary.right == NULL) {
error(parser, parser->previous, "Expected function call after dot operator");
return OP_EOF;
}
//hijack the function call, and hack in an extra parameter
node->binary.right->fnCall.argumentCount++;
node->binary.opcode = OP_DOT;