Skip to content

Commit

Permalink
Fix panic error when evaluating an empty expression
Browse files Browse the repository at this point in the history
  • Loading branch information
stirante committed Aug 9, 2024
1 parent e9ffd3d commit f925ab3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion jsonte/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func EvalScript(text string, scope deque.Deque[*types.JsonObject], path string)
p.BuildParseTrees = true
tree := p.Script()
if listener.Error != nil {
return Result{}, burrito.WrapErrorf(listener.Error, "Failed to parse expression \"%s\"", text)
return Result{}, burrito.WrapErrorf(listener.Error, "Failed to parse script \"%s\"", text)
}
visitor := ExpressionVisitor{
scope: scope,
Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,9 @@ func repl(scope *types.JsonObject) {
fmt.Println(err)
} else {
fmt.Println(types.ToString(eval.Value))
}
if !eval.VariableScope.IsEmpty() {
s.PushBack(eval.VariableScope)
if !eval.VariableScope.IsEmpty() {
s.PushBack(eval.VariableScope)
}
}
fmt.Print("> ")
}
Expand Down

0 comments on commit f925ab3

Please sign in to comment.