From f925ab3bb5bb2e4290563998d779e946ed006fbf Mon Sep 17 00:00:00 2001 From: stirante Date: Fri, 9 Aug 2024 13:01:41 +0200 Subject: [PATCH] Fix panic error when evaluating an empty expression --- jsonte/evaluator.go | 2 +- main.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/jsonte/evaluator.go b/jsonte/evaluator.go index 2cb19d4..19cea10 100644 --- a/jsonte/evaluator.go +++ b/jsonte/evaluator.go @@ -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, diff --git a/main.go b/main.go index 5f9b2e5..82eef33 100644 --- a/main.go +++ b/main.go @@ -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("> ") }