Tuple equality comparison limitations - Is this "problem" due to System.ValueTuple or VB?
- Dominant language
- No language data
- Stars
- 328
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
From the code below:
```
Dim z As (a As Integer, b As Integer) = (5, 10)
Dim q = (6, 12)
Dim ok_true = z.Equals((5, 10))
Dim ok_false = q.Equals(z)
Dim nocompile_true = (z = (5, 10))
Dim nocompile_false = (q = z)
```
ok_true and ok_false work fine.
nocompile_true gives error:
`BC30452 Operator '=' is not defined for types '(a As Integer, b As Integer)' and '(Integer, Integer)'`
nocompile_false gives error:
`BC30452 Operator '=' is not defined for types '(Integer, Integer)' and '(a As Integer, b As Integer)'`
And comparing two literal tuples gives the same error:
`Dim nope = ((6, 10) = (6, 10))`
`BC30452 Operator '=' is not defined for types '(Integer, Integer)' and '(Integer, Integer)'`
So, is there a (good) reason that tuples can't be tested for equality using the = operator as long as all of the types of the individual elements are equatable? Besides the elements themselves, there isn't really anything else to compare, is there?
Could the compiler re-write the expression to perform individual element comparisons?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.