Skip to content
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

fix: Correctly infer type of numeric arguments when the type is a subset type of a newtype #2314

Merged
merged 11 commits into from
Jun 30, 2022

Conversation

RustanLeino
Copy link
Collaborator

Fixes #2307

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

cpitclaudel
cpitclaudel previously approved these changes Jun 29, 2022
Copy link
Member

@cpitclaudel cpitclaudel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, left some nitpicky comments

Source/Dafny/AST/DafnyAst.cs Outdated Show resolved Hide resolved
@@ -2061,14 +2060,12 @@ public enum AutoInitInfo { MaybeEmpty, Nonempty, CompilableValue }

var joinNeedsNonNullConstraint = false;
Type j;
if (a is UserDefinedType && ((UserDefinedType)a).ResolvedClass is NonNullTypeDecl) {
if ((a as UserDefinedType)?.ResolvedClass is NonNullTypeDecl aClass) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ((a as UserDefinedType)?.ResolvedClass is NonNullTypeDecl aClass) {
if (a is UserDefinedType { ResolvedClass: NonNullTypeDecl aClass }) {

Source/Dafny/AST/DafnyAst.cs Outdated Show resolved Hide resolved
Source/Dafny/AST/DafnyAst.cs Show resolved Hide resolved
Comment on lines 2146 to 2148
} else if (a.IsNumericBased()) {
return a.Equals(b) ? a : null;
} else if (a.IsBitVectorType) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you fold these two cases in the one above?

Source/Dafny/Resolver.cs Show resolved Hide resolved
cpitclaudel
cpitclaudel previously approved these changes Jun 29, 2022
@RustanLeino RustanLeino enabled auto-merge (squash) June 30, 2022 17:15
@RustanLeino RustanLeino merged commit bfec2e8 into dafny-lang:master Jun 30, 2022
@RustanLeino RustanLeino deleted the issue-2307 branch June 30, 2022 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type checker fails to infer types of constants as subset types of newtypes
2 participants