-
Notifications
You must be signed in to change notification settings - Fork 269
/
Copy pathgit-issue-1074.dfy
48 lines (40 loc) · 1.65 KB
/
git-issue-1074.dfy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// RUN: %build --verbose "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
module A {
// This test uses an abstract type as the type of "children" below. This once caused
// a crash in the compiler.
// To distinguish the crashing test output from the correct test output, we need to
// get to a point where the compiler prints some output. If the compilation succeeds,
// there will be some output. But to make the abstract type compile, it needs to be
// marked with an :extern that redirects it to some existing type. Rather than relying
// on some type in the C#-or-other-target runtime library, this test declares a class
// MyCollection, which is then named in the :extern attribute. (This relies on that
// "MyCollection" is not name mangled in the process.)
type {:extern "MyCollection"} Container<A>
class MyCollection<X> {
}
datatype Node = Leaf | Node(children: Container<Node>)
method Test(node: Node)
requires node.Node?
{
var Node(ch) := node; // this line once crashed the compiler
}
}
module B {
datatype InnerT<X> = Inner(x: X)
datatype Node<X, Y> = Leaf | Node(children: Y)
method Test(node: Node<int, InnerT<real>>)
requires node.Node?
{
var Node(Inner(z)) := node; // this once compiled into malformed code, because the compiler used "int" instead of "InnerT<real>" as the type of Inner(z)
}
}
module C {
datatype InnerT<X> = Inner(x: X)
datatype Node<X> = Leaf | Node(children: InnerT<X>)
method Test(node: Node<int>)
requires node.Node?
{
var Node(Inner(z)) := node; // this once compiled into malformed code, because the compiler used "X" instead of "InnerT<int>" as the type of Inner(z)
}
}