Skip to content

Commit

Permalink
Parse 'let' declarations as simple statements
Browse files Browse the repository at this point in the history
  • Loading branch information
klange committed Sep 13, 2022
1 parent a59b635 commit 564a4b3
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1202,19 +1202,13 @@ static void letDeclaration(struct GlobalState * state) {
}

_letDone:
if (!match(TOKEN_EOL) && !match(TOKEN_EOF)) {
errorAtCurrent("Expected end of line after 'let' statement.");
}

FREE_ARRAY(ssize_t,args,argSpace);
return;
}

static void declaration(struct GlobalState * state) {
if (check(TOKEN_DEF)) {
defDeclaration(state);
} else if (match(TOKEN_LET)) {
letDeclaration(state);
} else if (check(TOKEN_CLASS)) {
KrkToken className = classDeclaration(state);
size_t classConst = identifierConstant(state, &className);
Expand Down Expand Up @@ -2521,6 +2515,8 @@ static void simpleStatement(struct GlobalState * state) {
assertStatement(state);
} else if (match(TOKEN_PASS)) {
/* Do nothing. */
} else if (match(TOKEN_LET)) {
letDeclaration(state);
} else {
expressionStatement(state);
}
Expand Down

0 comments on commit 564a4b3

Please sign in to comment.