Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cty: handle deep marks in Equals #112

Merged
merged 1 commit into from Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions cty/value_ops.go
Expand Up @@ -116,9 +116,9 @@ func (val Value) GoString() string {
// Use RawEquals to compare if two values are equal *ignoring* the
// short-circuit rules and the exception for null values.
func (val Value) Equals(other Value) Value {
if val.IsMarked() || other.IsMarked() {
val, valMarks := val.Unmark()
other, otherMarks := other.Unmark()
if val.ContainsMarked() || other.ContainsMarked() {
val, valMarks := val.UnmarkDeep()
other, otherMarks := other.UnmarkDeep()
return val.Equals(other).WithMarks(valMarks, otherMarks)
}

Expand Down
10 changes: 10 additions & 0 deletions cty/value_ops_test.go
Expand Up @@ -753,6 +753,16 @@ func TestValueEquals(t *testing.T) {
StringVal("b").Mark(2),
False.WithMarks(NewValueMarks(1, 2)),
},

{
MapVal(map[string]Value{
"a": StringVal("a").Mark("boop"),
}),
MapVal(map[string]Value{
"a": StringVal("a").Mark("blop"),
}),
True.WithMarks(NewValueMarks("boop", "blop")),
},
}

for _, test := range tests {
Expand Down