-
Notifications
You must be signed in to change notification settings - Fork 256
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
Debug Equality #2768
Debug Equality #2768
Conversation
…e and checking opaque types
…/dafny into jtristan-issue-1427-2070-1429
…arguments might not have been computed yet
… of through the SupportsEquality property
…rators and type arguments
…gonal to 1427 and 1429
…se recursion issues
…3 constructors incorrectly using a type that does not support equality as the domain of sets or maps
…+ allowing opaques to declare equality support
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great improvement but a few things are still missing.
First, the check is a bit too strict: not all type parameters participate in equality, and hence not we do not need to check for equality (or add a dependency edge) between all type parameters. Your code rejects this, but I think it should be accepted?
type DoesNotSupportEq = int -> int
type AlwaysSupportsEq<A> = int
datatype SupportsEqDespiteParameter =
SupportsEq(a: AlwaysSupportsEq<DoesNotSupportEq>)
type T_SupportsEqDespiteParameter(==) =
SupportsEqDespiteParameter
On the other hand, the check is not strict enough wrt opaque types, because it does not skip past subtype constraints. Your code accepts this, but I think it should be rejected:
type foo
type foo' = f: foo | true witness *
datatype NeverEq' = NeverEq'(f: foo')
type T_NeverEq'(==) = NeverEq'
I believe this PR covers the same issues as #2066, so it would be good to see what is done there (and probably import the tests, too).
In particular, I think you may want to use the NecessaryForEqualitySupportOfSurroundingInductiveDatatype
field of type arguments, but only in the case where the datatype is marked as ConsultTypeArgs
.
Co-authored-by: Clément Pit-Claudel <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've gone through the code, but I don't understand everything fully yet. In particular:
- I'm puzzled by the loop on the type arguments of the original type inside the loop on the type arguments of the construct's argument,
- I'm confused by the use of AsRedirectingType, which is an internal property that I'm not sure we should be using here.
- I don't fully understand why we're computing whether a type definitely can't support equality (instead of possibly can't support equality / definitely supports equality)
Co-authored-by: Clément Pit-Claudel <[email protected]>
Co-authored-by: Clément Pit-Claudel <[email protected]>
Following up on my confusion, here's a program that still crashes in the current implementation:
|
Co-authored-by: Clément Pit-Claudel <[email protected]>
Co-authored-by: Clément Pit-Claudel <[email protected]>
Co-authored-by: Clément Pit-Claudel <[email protected]>
Co-authored-by: Clément Pit-Claudel <[email protected]>
To give some context, the goal of this PR is not to fix all know issues with the equality support. For example, I am not trying to address #2070. The goal is only to address some issues such as #1427 or #1429, where the problem is that the existing code that filters out datatypes that are known for sure not to support equality is too weak. It is possible that it is not overall the best approach to first filter out such datatypes, but my goal has not been to rethink the equality support determination entirely, only to fix errors in the existing one. |
As you should, it was an error.
I do this to access the type parameters of the underlying type definition, but I will try to see if there is a better way to do this.
CF other comment on scope of this PR |
Fixes #1427 #1429