Added partial expr replacement for for-expr
@@ -118,11 +118,13 @@ func newLiteralValueExpr(ctx *hcl.EvalContext, exp hcl.Expression) hclsyntax.Exp
}
return expr
case *hclsyntax.ForExpr:
- // TODO: handle for cases
- //expr.CollExpr = newLiteralValueExpr(ctx, expr.CollExpr)
- //expr.CondExpr = newLiteralValueExpr(ctx, expr.CondExpr)
- //expr.KeyExpr = newLiteralValueExpr(ctx, expr.KeyExpr)
- //expr.ValExpr = newLiteralValueExpr(ctx, expr.ValExpr)
+ // expr.CollExpr can't be null
+ // TODO: CondExpr must use local variables to get a non nil-literal
+ //expr.CondExpr = newLiteralValueExpr(ctx, expr.CondExpr) // null without 'if' and must result in bool
+ if expr.KeyExpr != nil { // nil if producing a tuple
+ expr.KeyExpr = newLiteralValueExpr(ctx, expr.KeyExpr)
+ }
+ expr.ValExpr = newLiteralValueExpr(ctx, expr.ValExpr)
return expr
case *hclsyntax.ParenthesesExpr:
expr.Expression = newLiteralValueExpr(ctx, expr.Expression)
