hclsyntax: Highlight key expression on invalid key type in object cons
Previously we were incorrectly indicating the value expression as the problem. This fixes #54.
This commit is contained in:
parent
1681396757
commit
17ab3729e7
@ -727,8 +727,8 @@ func (e *ObjectConsExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics
|
|||||||
Severity: hcl.DiagError,
|
Severity: hcl.DiagError,
|
||||||
Summary: "Incorrect key type",
|
Summary: "Incorrect key type",
|
||||||
Detail: fmt.Sprintf("Can't use this value as a key: %s.", err.Error()),
|
Detail: fmt.Sprintf("Can't use this value as a key: %s.", err.Error()),
|
||||||
Subject: item.ValueExpr.Range().Ptr(),
|
Subject: item.KeyExpr.Range().Ptr(),
|
||||||
Expression: item.ValueExpr,
|
Expression: item.KeyExpr,
|
||||||
EvalContext: ctx,
|
EvalContext: ctx,
|
||||||
})
|
})
|
||||||
known = false
|
known = false
|
||||||
|
@ -403,6 +403,12 @@ upper(
|
|||||||
}),
|
}),
|
||||||
0,
|
0,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
`{[]: "yes"}`,
|
||||||
|
nil,
|
||||||
|
cty.DynamicVal,
|
||||||
|
1, // Incorrect key type; Can't use this value as a key: string required
|
||||||
|
},
|
||||||
{
|
{
|
||||||
`{"hello" = "world", "goodbye" = "cruel world"}`,
|
`{"hello" = "world", "goodbye" = "cruel world"}`,
|
||||||
nil,
|
nil,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user