summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2022-04-09 16:22:55 -0400
committerKyle Gunger <kgunger12@gmail.com>2022-04-09 16:22:55 -0400
commit5b721bf57c2a8cf6b2f86dc893a61dc208715426 (patch)
tree516b23ce18608d69e76d7d5f4b78af039193518f
parent3f132f186af8073226e3b88b53d7eebda564554c (diff)
[EXEC] Hotfix for loops without parameters
-rw-r--r--src/texec/eval.go22
1 files changed, 12 insertions, 10 deletions
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)
+ }
}
}
}