Skip to content

Commit ae6749e

Browse files
authored
Pass only type to EvalExpr when passed detailed types (#107)
1 parent 0849939 commit ae6749e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tflint/client/client.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@ func (c *Client) EvaluateExpr(expr hcl.Expression, ret interface{}, wantType *ct
246246
}
247247

248248
var response EvalExprResponse
249-
req := EvalExprRequest{Ret: ret, Type: *wantType}
249+
req := EvalExprRequest{Type: *wantType}
250+
if req.Type == (cty.Type{}) {
251+
req.Ret = ret
252+
}
250253
req.Expr, req.ExprRange = encodeExpr(file.Bytes, expr)
251254
if err := c.rpcClient.Call("Plugin.EvalExpr", req, &response); err != nil {
252255
return err
@@ -285,7 +288,10 @@ func (c *Client) EvaluateExprOnRootCtx(expr hcl.Expression, ret interface{}, wan
285288
}
286289

287290
var response EvalExprResponse
288-
req := EvalExprRequest{Ret: ret, Type: *wantType}
291+
req := EvalExprRequest{Type: *wantType}
292+
if req.Type == (cty.Type{}) {
293+
req.Ret = ret
294+
}
289295
req.Expr, req.ExprRange = encodeExpr(file.Bytes, expr)
290296
if err := c.rpcClient.Call("Plugin.EvalExprOnRootCtx", req, &response); err != nil {
291297
return err

0 commit comments

Comments
 (0)