Skip to content

fix: Fix crash when a simple forall statement was placed inside a match#6121

Merged
RustanLeino merged 4 commits into
dafny-lang:masterfrom
RustanLeino:issue-6120
Feb 24, 2025
Merged

fix: Fix crash when a simple forall statement was placed inside a match#6121
RustanLeino merged 4 commits into
dafny-lang:masterfrom
RustanLeino:issue-6120

Conversation

@RustanLeino

Copy link
Copy Markdown
Collaborator

Fixes #6120

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

@RustanLeino RustanLeino changed the title Fix crash when a simple forall statement was placed inside a match fix: Fix crash when a simple forall statement was placed inside a match Feb 22, 2025
@RustanLeino RustanLeino marked this pull request as ready for review February 22, 2025 03:31
@RustanLeino RustanLeino enabled auto-merge (squash) February 22, 2025 03:31
@RustanLeino RustanLeino merged commit cd5902f into dafny-lang:master Feb 24, 2025
@RustanLeino RustanLeino deleted the issue-6120 branch February 24, 2025 22:18
fabiomadge added a commit that referenced this pull request Jun 30, 2025
Addresses issue #6268 by identifying and partially fixing the root cause.

ROOT CAUSE DISCOVERED: Cloning Issue (similar to #6121)
- In match cases, HideRevealStmt objects are cloned during desugaring
- Cloning creates new AssertLabel objects without preserving E field
- Original AssertLabel objects get E field filled during Boogie generation
- Cloned AssertLabel objects accessed by reveal statements have null E field
- Contract.Assert(la.E != null) crashes when accessing cloned objects

THE FIX: Graceful Null Handling
- Skip processing AssertLabel objects with null E field
- Prevents crash but doesn't restore full functionality
- Reveal statements in match cases don't work but don't crash

LIMITATION: Functionality Not Fully Restored
- This prevents the crash but reveal statements don't work in match cases
- Full fix would require connecting cloned objects to original translated expressions
- Similar pattern to ForallStmt fix in #6121 but more complex due to E field timing

This demonstrates the cloning issue pattern and provides crash prevention
while acknowledging the need for a more complete architectural solution.
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.

Bland forall in match causes crash

2 participants