Fixed some indexing bugs

This commit is contained in:
2022-09-07 18:43:32 +01:00
parent 8f61575579
commit 9a55ff221a
7 changed files with 89 additions and 32 deletions

View File

@@ -736,17 +736,24 @@ static Opcode indexAccess(Parser* parser, Node** nodeHandle) {
emitNodeLiteral(&second, TO_BOOLEAN_LITERAL(true));
emitNodeLiteral(&third, TO_BOOLEAN_LITERAL(true));
bool readFirst = false; //pattern matching is bullcrap
//eat the first
if (!match(parser, TOKEN_COLON)) {
freeNode(first);
parsePrecedence(parser, &first, PREC_TERNARY);
match(parser, TOKEN_COLON);
readFirst = true;
}
if (match(parser, TOKEN_BRACKET_RIGHT)) {
freeNode(second);
if (readFirst) {
freeNode(second);
second = NULL;
}
freeNode(third);
second = NULL;
third = NULL;
emitNodeIndex(nodeHandle, first, second, third);