Ensure that scopes are cleaned up correctly upon error. (#20)

When evaluating rules, upon error the last pushed scope wasn't being
popped from the stack of scopes. This causes incorrect behavior
when there are multiple definitions for the same rule name.

The fix is to make sure that the scopes are popped manually upon encountering errors.

Once the interpreter logic is locked down, then we need to clean up scope management
using Drop functions so that the cleanup happens even during short circuited return.

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2023-06-23 08:57:47 -07:00
committed by GitHub
parent e08d13df53
commit 796da46ae8
3 changed files with 18 additions and 15 deletions
+3 -5
View File
@@ -130,10 +130,8 @@ cases:
a2 = fcn(5)
query: data.test
want_result:
a1:
set!: [hello world]
a2:
set!: [6]
a1: "hello world"
a2: 6
- note: or-all-error
data: {}
@@ -151,4 +149,4 @@ cases:
a1 = fcn("world")
query: data.test
error: "`add` expects numeric argument. Got `\"world\"` instead"
error: "`add` expects numeric argument. Got `\"world\"` instead"