-
Notifications
You must be signed in to change notification settings - Fork 254
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
Support members for the new newtypes #5311
Conversation
# Conflicts: # Source/DafnyCore/Resolver/CheckTypeCharacteristics_Visitor.cs # Source/DafnyCore/Rewriters/RefinementErrors.cs # Source/DafnyCore/Rewriters/RefinementTransformer.cs # docs/HowToFAQ/Errors-Refinement.md
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.
A few comments here and there, but I'm happy with this very well tested PR otherwise!
} | ||
} | ||
} | ||
if (prevErrorCount == reporter.Count(ErrorLevel.Error)) { |
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 If statement has not been moved, just deleted. Could you please confirm why?
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.
Thanks for noticing. Yes, this is as intended. The RegisterInheritedMembers
and InheritedTraitMembers
methods had been responsible for bringing in the members from a type's trait parents. With the more general newtype
s, a newtype
can now inherit members also from its base type. However, the base type is, in general, not known this early in the resolution pipeline. Therefore, the functionality of RegisterInheritedMembers
and InheritedTraitMembers
was moved into "pass 0" of the resolver.
@@ -1,4 +1,4 @@ | |||
git-issue-2303.dfy(5,10): Error: newtype's base type is not fully determined; add an explicit type for bound variable 'x' | |||
git-issue-2303.dfy(5,10): Error: base type of newtype 'int0' is not fully determined; add an explicit type for bound variable 'x' |
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.
Good job making the message a bit more explicit
type seq<+T> { } | ||
|
||
type multiset<+T> { } | ||
|
||
type map<+T, +U> { | ||
var Keys: set<T> // immutable |
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.
Immutable with var? Shouldn't it be const?
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.
Good call. I changed the printing code to output these SpecialField
s as const
.
Co-authored-by: Mikaël Mayer <[email protected]>
Co-authored-by: Mikaël Mayer <[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.
Looks great ! Approved a priori. Did you also ensure that the type characteristics were matched?
No new cases needed to be checked. Unlike members inherited from a parent trait, the members that are inherited from the base type already have a body and cannot be overridden. |
This PR adds support for members of the recently expanded newtypes. In particular, inheritance of user-defined members and built-in members (such as
.RotateLeft
for bitvector types) are handled. Under--general-trait=full
, inheritance from bothnewtype
base types and parent traits are handled.A
newtype
's inherited members can only be figured out once thenewtype
's base type is known. Since the base type is in general inferred, this means that member registration cannot happen until resolution has started. So, this PR moves that process fromRegister...
toResolve...
.As part of this PR, other built-in types (
char
,set
, ...) were added to thevaluetypeDecls
array. This has an effect on the--rprint
output.The PR also improves some error messages (e.g., making them more consistent by using the format
type 'T'
) and removes some unused code that was left in abandoned#if ...
directives during the resolver refresh.By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.