Skip to content

Commit ce534d0

Browse files
authored
Forward to 1.6.1 (#16)
1 parent 0fdcf0e commit ce534d0

File tree

4 files changed

+804
-26
lines changed

4 files changed

+804
-26
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
language: go
22

33
go:
4-
- 1.11.x
5-
- 1.12.x
4+
- 1.13.x
65
- tip
76

87
before_install:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.6.1 (Unreleased)
2+
3+
* Fix a regression from 1.6.0 where `Value.RawEqual` no longer returned the correct result given a pair of sets containing partially-unknown values. ([#64](https://github.com/zclconf/go-cty/pull/64))
4+
15
# 1.6.0 (Unreleased)
26

37
* Fixed various defects in the handling of sets containing unknown values. This will cause unknown values to now be returned in more situations, whereas before `cty` would often return incorrect results when working with sets containing unknown values. The list of defects fixed in this release includes:

cty/value_ops.go

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -465,35 +465,27 @@ func (val Value) RawEquals(other Value) bool {
465465
return false
466466

467467
case ty.IsSetType():
468-
s1 := val.v.(set.Set)
469-
s2 := other.v.(set.Set)
470-
471-
// Raw equality for sets is a little tricky because our rules for a
472-
// set of values say that unknown values are never equal. However,
473-
// if both physical sets have the same length and they have all of
474-
// their _known_ values in common, we know that both sets also have
475-
// the same number of unknown values.
476-
if s1.Length() != s2.Length() {
468+
// Convert the set values into a slice so that we can compare each
469+
// value. This is safe because the underlying sets are ordered (see
470+
// setRules in set_internals.go), and so the results are guaranteed to
471+
// be in a consistent order for two equal sets
472+
setList1 := val.AsValueSlice()
473+
setList2 := other.AsValueSlice()
474+
475+
// If both physical sets have the same length and they have all of their
476+
// _known_ values in common, we know that both sets also have the same
477+
// number of unknown values.
478+
if len(setList1) != len(setList2) {
477479
return false
478480
}
479-
for it := s1.Iterator(); it.Next(); {
480-
v := it.Value()
481-
if v == unknown { // "unknown" is the internal representation of unknown-ness
482-
continue
483-
}
484-
if !s2.Has(v) {
485-
return false
486-
}
487-
}
488-
for it := s2.Iterator(); it.Next(); {
489-
v := it.Value()
490-
if v == unknown { // "unknown" is the internal representation of unknown-ness
491-
continue
492-
}
493-
if !s1.Has(v) {
481+
482+
for i := range setList1 {
483+
eq := setList1[i].RawEquals(setList2[i])
484+
if !eq {
494485
return false
495486
}
496487
}
488+
497489
// If we got here without returning false already then our sets are
498490
// equal enough for RawEquals purposes.
499491
return true

0 commit comments

Comments
 (0)