Skip to content

Commit 5f74d6a

Browse files
authored
Fix: No new resolver crash with partially resolved datatype update expressions (#5440)
Fixes #5331 Fixes #5365 The only part that fixes the issue is the last line end of the file PreTypeResolve.Expressions.cs, the rest is an automated conversion If/then/else to a switch statement that helped debugging and makes the code easier to maintain. <small>By submitting this pull request, I confirm that my contribution is made under the terms of the [MIT license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
1 parent 709edd1 commit 5f74d6a

File tree

6 files changed

+713
-623
lines changed

6 files changed

+713
-623
lines changed

Source/DafnyCore/Resolver/PreType/PreTypeResolve.Expressions.cs

+682-623
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %baredafny verify %args --type-system-refresh "%s" > "%t"
2+
// RUN: %diff "%s.expect" "%t"
3+
4+
trait Ins {
5+
function step(s:State):State //requires safe?(s)
6+
}
7+
type Code = seq<Ins>
8+
datatype State = S(
9+
clock:nat
10+
) {
11+
function fetch_():Ins
12+
const fetch := fetch_()
13+
const step := fetch.step(this)
14+
function run():State decreases clock {
15+
if clock == 0 then this else step.(clock := clock - 1).run()
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
Dafny program verifier finished with 2 verified, 0 errors
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %baredafny verify %args --type-system-refresh "%s" > "%t"
2+
// RUN: %diff "%s.expect" "%t"
3+
4+
datatype S = S(
5+
n:nat
6+
) {
7+
function f():S { this }
8+
function g():S { this.(n := 0).f() }
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
Dafny program verifier finished with 1 verified, 0 errors

docs/dev/news/5331.fix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
No new resolver crash when datatype update expressions are partially resolved

0 commit comments

Comments
 (0)