From be3bb12f28540f43a7ca61c4fc578253ab534ffc Mon Sep 17 00:00:00 2001 From: Celestino Amoroso Date: Sat, 13 Jul 2024 09:07:33 +0200 Subject: [PATCH] operator-unset.go: fixed function removal --- operator-unset.go | 2 +- t_operator_test.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/operator-unset.go b/operator-unset.go index b3a1520..3910464 100644 --- a/operator-unset.go +++ b/operator-unset.go @@ -23,7 +23,7 @@ func deleteContextItem(ctx ExprContext, opTerm *term, item any) (deleted bool, e var size int if strings.HasSuffix(name, "()") { size = ctx.FuncCount() - ctx.DeleteVar(strings.TrimRight(name, "()")) + ctx.DeleteFunc(strings.TrimRight(name, "()")) deleted = ctx.FuncCount() < size } else { size = ctx.VarCount() diff --git a/t_operator_test.go b/t_operator_test.go index 2346212..1ff894b 100644 --- a/t_operator_test.go +++ b/t_operator_test.go @@ -13,10 +13,11 @@ func TestOperator(t *testing.T) { inputs := []inputType{ /* 1 */ {`a=1; unset "a"; a`, nil, `undefined variable or function "a"`}, /* 2 */ {`a=1; unset ["a", "b"]`, int64(1), nil}, + /* 3 */ {`f=func(){3}; unset "f()"`, int64(1), nil}, } // t.Setenv("EXPR_PATH", ".") - runTestSuiteSpec(t, section, inputs, 2) - //runTestSuite(t, section, inputs) + //runTestSuiteSpec(t, section, inputs, 3) + runTestSuite(t, section, inputs) }