diff --git a/ops.go b/ops.go index 5d2910c..20c8039 100644 --- a/ops.go +++ b/ops.go @@ -217,7 +217,12 @@ func GetAttr(obj cty.Value, attrName string, srcRange *Range) (cty.Value, Diagno } idx := cty.StringVal(attrName) - if obj.HasIndex(idx).False() { + + // Here we drop marks from HasIndex result, in order to allow basic + // traversal of a marked map in the same way we can traverse a marked + // object + hasIndex, _ := obj.HasIndex(idx).Unmark() + if hasIndex.False() { return cty.DynamicVal, Diagnostics{ { Severity: DiagError, diff --git a/ops_test.go b/ops_test.go index befebc8..39b748f 100644 --- a/ops_test.go +++ b/ops_test.go @@ -48,6 +48,15 @@ func TestApplyPath(t *testing.T) { cty.StringVal("hello"), ``, }, + { + cty.MapVal(map[string]cty.Value{ + "a": cty.StringVal("foo").Mark("x"), + "b": cty.StringVal("bar").Mark("x"), + }).Mark("x"), + cty.GetAttrPath("a"), + cty.StringVal("foo").Mark("x"), + ``, + }, { cty.ListValEmpty(cty.String), (cty.Path)(nil).Index(cty.NumberIntVal(0)),