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: Optional pre-type won't cause a crash anymore #5442

Merged
merged 9 commits into from
May 17, 2024
Prev Previous commit
Next Next commit
Update fix and expect file
  • Loading branch information
keyboardDrummer committed May 17, 2024
commit 0faf79386f1e6ceb53cd1d66e9bb34b7440f5095
2 changes: 0 additions & 2 deletions Source/DafnyCore/Resolver/PreType/PreTypeConstraints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,6 @@ public enum CommonConfirmationBag {
preType = preType.Normalize();
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment to ConfirmConstraint, or update its signature (parameter names) to make it clear what it does? I don't understand the meaning of the parameters or return value by looking at just its signature and comment.

Copy link
Member Author

@MikaelMayer MikaelMayer May 16, 2024

Choose a reason for hiding this comment

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

I can't, as I don't understand the code at a level high enough to do that. I don't have a mental model of what ConfirmConstraint does, nor about what code context it was called with. I'll leave it for @RustanLeino to comment on it.

if (preType is PreTypeProxy) {
return false;
} else if (preType is MethodPreType) {
return true;
}

var pt = (DPreType)preType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1591,6 +1591,7 @@ public partial class PreTypeResolver {
if (!allowMethodCall) {
// it's a method and method calls are not allowed in the given resolutionContext
ReportError(tok, "expression is not allowed to invoke a {0} ({1})", member.WhatKind, member.Name);
return null;
}
int suppliedTypeArguments = optTypeArguments == null ? 0 : optTypeArguments.Count;
if (optTypeArguments != null) {
Expand Down
2 changes: 1 addition & 1 deletion Source/DafnyCore/Resolver/ResolutionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public ResolutionContext(ICodeContext codeContext, bool isTwoState)
if (CodeContext.IsGhost == isGhost) {
return this;
}
return new ResolutionContext(new CodeContextWrapper(CodeContext, isGhost), IsTwoState, InOld, InReveal, InFunctionPostcondition, InFirstPhaseConstructor);
return this with { CodeContext = new CodeContextWrapper(CodeContext, isGhost) };
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
git-issue-5369.dfy(20,2): Error: expression is not allowed to invoke a method (m)
git-issue-5369.dfy(20,40): Error: expression is not allowed to invoke a method (m)
git-issue-5369.dfy(20,42): Error: arguments to <= must have a common supertype (got int and (unused -- call to method m))
git-issue-5369.dfy(20,4): Error: expecting element type to be assignable to nat (got (unused -- call to method m))
git-issue-5369.dfy(32,9): Error: unresolved identifier: ThereIsASmallest
5 resolution/type errors detected in git-issue-5369.dfy
3 resolution/type errors detected in git-issue-5369.dfy
Loading