From 5b721bf57c2a8cf6b2f86dc893a61dc208715426 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Sat, 9 Apr 2022 16:22:55 -0400 Subject: [EXEC] Hotfix for loops without parameters --- src/texec/eval.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/texec') diff --git a/src/texec/eval.go b/src/texec/eval.go index a2c7b8d..f28cf9c 100644 --- a/src/texec/eval.go +++ b/src/texec/eval.go @@ -1039,7 +1039,7 @@ func evalCF(v tparse.Node, ctx *VarMap) (bool, TVariable, int) { var after *tparse.Node = nil if v.Sub[0].Data.Data == "bdef" { - var before *tparse.Node + var before *tparse.Node = nil for i := 0; i < len(v.Sub[0].Sub); i++ { switch v.Sub[0].Sub[i].Data.Data { @@ -1052,15 +1052,17 @@ func evalCF(v tparse.Node, ctx *VarMap) (bool, TVariable, int) { } } - for i := 0; i < len(before.Sub); i++ { - switch before.Sub[i].Data.Data { - case "define": - evalDef(before.Sub[i], ctx) - case "value": - val := *evalValue(before.Sub[i].Sub[0], ctx) - if i == len(before.Sub) - 1 && equateType(val.Type, tBool) { - cond = before.Sub[i].Sub[0] - ifout = val.Data.(bool) + if before != nil { + for i := 0; i < len(before.Sub); i++ { + switch before.Sub[i].Data.Data { + case "define": + evalDef(before.Sub[i], ctx) + case "value": + val := *evalValue(before.Sub[i].Sub[0], ctx) + if i == len(before.Sub) - 1 && equateType(val.Type, tBool) { + cond = before.Sub[i].Sub[0] + ifout = val.Data.(bool) + } } } } -- cgit v1.2.3