-
Notifications
You must be signed in to change notification settings - Fork 285
Prepare for making new resolver the default #5653
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
Prepare for making new resolver the default #5653
Conversation
comp/Class.dfy
The 1 more verified comes from the type of {}. It’s really inferred to be set<object?_\bot>, but this is later turned into just set<object?>.
Found via traits/TraitResolution1.dfy
| } | ||
|
|
||
| public static IEnumerable<MemberDecl> AllMembers(IEnumerable<TopLevelDecl> declarations) { | ||
| foreach (var decl in declarations.OfType<TopLevelDeclWithMembers>()) { |
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.
better to use declarations.OfType<TopLevelDeclWithMembers>().SelectMany(d => d.Members)
| public static readonly Option<bool> TypeSystemRefresh = new("--type-system-refresh", () => false, | ||
| @" | ||
| false - The type-inference engine and supported types are those of Dafny 4.0. | ||
| false (default) - The type-inference engine and supported types are those of Dafny 4.0. |
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.
| Constraints.AddConfirmation(tok, () => CheckComparableTypes(a, b, allowBaseTypeCast), errorMessage); | ||
| } | ||
|
|
||
| private void AddComparableTypesDefault(PreType a, PreType b) { |
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.
Would be good to have an example of what Dafny code this is could help with
| } | ||
| case LiteralExpr: | ||
| CheckResultToBeInType(expr.Origin, expr, expr.Type, locals, builder, etran); | ||
| if (expr is StringLiteralExpr stringLiteralExpr) { |
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.
What's this about?
|
|
||
| function Object(js: Grammar.jobject): DeserializationResult<seq<(string, Values.JSON)>> { | ||
| Seq.MapWithResult(d requires d in js.data => KeyValue(d.t), js.data) | ||
| var f := d requires d in js.data => KeyValue(d.t); |
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.
Why is this needed?
From a user's perspective, this is a regression of the type system, right? I see quite a few changes were made in the standard library to accommodate for this change. |
| assert sep.StrictlySplitFrom?(elem.cs, c => Spec.Structural(c, SpecView)) by { | ||
| assert sep.BytesSplitFrom?(elem.cs, c => Spec.Structural(c, SpecView)) by { | ||
| assert sep.SplitFrom?(elem.cs, c => Spec.Structural(c, SpecView)); | ||
| assert sep.StrictlySplitFrom?(elem.cs, (c: Structural<jcomma>) => Spec.Structural(c, SpecView)) by { |
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.
These types of changes are not exactly pretty. What's the trade-off here?
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 committed a few small changes. Approving, although the change to no longer infer subset types for bound variables makes user code less readable. What would it take to enable that?
Ideally we would enable that before moving the stdlib to the new resolver, so it would not need many of the changes it got now.
# Conflicts: # Source/DafnyCore/AST/TypeDeclarations/Declaration.cs
|
Thanks for the review, changes, and comments. I will merge this into
This change was in the new resolver before. That is, this PR does not change this behavior. The old resolver could infer bound variables as subset types, but that can potentially create surprises. For example, given predicate P(n: nat, s: string)
predicate Q(s: string)consider inferring the type of forall x, s :: if 0 <= x then P(x, s) else Q(s)If the type of |

This PR prepares for making the new resolver the default (i.e., making
--type-system-refresh --general-traits=datatype --general-newtypesthe default), but it does not actually change the default.%testDafnyForEachResolverand%testDafnyForEachCompileruse both the old and new resolver.AutoExtern, and documentation to use the new resolver.This PR does not change the default resolver. So, users of the old resolver are mostly unaffected, and users of the new resolver obtain the PR's bug fixes.
Commnents for reviewers
The behavior of the resolver requires changes in some Dafny code, which affects the test suite:
extends object.int), never of a subset type (likenat).Sometimes, the tests show a different number of things verified. That's because the new or old type system takes care of all the proof obligations.
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.