Skip to content

Commit

Permalink
throw during reassignment if variable not found
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTrio committed Oct 28, 2024
1 parent 66dbb46 commit 103d0b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "espressolang",
"version": "1.1.5",
"version": "1.1.6",
"repository": {
"url": "https://github.com/TheTrio/Espresso"
},
Expand Down
11 changes: 11 additions & 0 deletions src/evaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ const evaluateReassignmentStatement = (
}
currentStore = currentStore.parentStore!
}
if (statement.lvalue instanceof IndexExpression) {
throw new VariableNotFoundError(
statement.lvalue.left.node.value!,
statement.lvalue.left.node.line
)
} else {
throw new VariableNotFoundError(
statement.lvalue!.value!,
statement.lvalue!.line
)
}
}

const getValueFromLValue = (lvalue: LValue, store: Store) => {
Expand Down

0 comments on commit 103d0b7

Please sign in to comment.