lang: EvalExpr only convert if wantType is not dynamic
This actually seems to be a bug in the underlying cty Convert function since converting to cty.DynamicPseudoType should always just return the input verbatim, but it seems like it's actually converting unknown values of any type to be cty.DynamicVal, losing the type information. We should eventually fix this in cty too, but having this extra check in the Terraform layer is harmless and allows us to make progress without context-switching.
This commit is contained in:
parent
bf25e12792
commit
e63a1dfb96
|
@ -88,6 +88,7 @@ func (s *Scope) EvalExpr(expr hcl.Expression, wantType cty.Type) (cty.Value, tfd
|
|||
val, evalDiags := expr.Value(ctx)
|
||||
diags = diags.Append(evalDiags)
|
||||
|
||||
if wantType != cty.DynamicPseudoType {
|
||||
var convErr error
|
||||
val, convErr = convert.Convert(val, wantType)
|
||||
if convErr != nil {
|
||||
|
@ -99,6 +100,7 @@ func (s *Scope) EvalExpr(expr hcl.Expression, wantType cty.Type) (cty.Value, tfd
|
|||
Subject: expr.Range().Ptr(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return val, diags
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue