-
Notifications
You must be signed in to change notification settings - Fork 267
/
Copy pathgit-issue-1180a.dfy
235 lines (225 loc) · 7.98 KB
/
git-issue-1180a.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
// RUN: %exits-with 2 %verify --show-hints "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
// resolution errors
module BadRefiningIndications {
type Opaque ... // error: uses ... but there's nothing to refine
type Opaque' ... { } // error: uses ... but there's nothing to refine
datatype Datatype ... // error: uses ... but there's nothing to refine
codatatype Codatatype ... // error: uses ... but there's nothing to refine
newtype Newtype ... // error: uses ... but there's nothing to refine
class Class ... { } // error: uses ... but there's nothing to refine
trait Trait ... { } // error: uses ... but there's nothing to refine
}
module EmptyRefinementParent { }
module MoreBadRefiningIndications refines EmptyRefinementParent {
type Opaque ... // error: uses ... but there's nothing to refine
type Opaque' ... { } // error: uses ... but there's nothing to refine
datatype Datatype ... // error: uses ... but there's nothing to refine
codatatype Codatatype ... // error: uses ... but there's nothing to refine
newtype Newtype ... // error: uses ... but there's nothing to refine
class Class ... { } // error: uses ... but there's nothing to refine
trait Trait ... { } // error: uses ... but there's nothing to refine
}
module StartingFromOpaqueType {
abstract module A {
type Ty<X> {
const c: nat
function F(x: nat): nat
method M(x: nat) returns (r: nat)
}
}
module OpaqueType refines A {
type Ty<X, Y> ... { // error: wrong number of type parameters
function F<Z>(x: nat): Z // error (x2): wrong number of type parametes, and wrong result type
method M<Z>(x: nat) returns (r: Z) { r := c; } // error (x2): wrong number of type parameters, and wrong out-parameter type
}
}
module Datatype refines A {
datatype Ty = Make(x: int) { // error: wrong number of type parameters
function F<Z>(x: nat): Z // error (x2): wrong number of type parametes, and wrong result type
method M<Z>(x: nat) returns (r: Z) { r := c; } // error (x2): wrong number of type parametes, and wrong out-parameter type
}
}
module Datatype' refines A {
datatype Ty<X> = Make(c: int, F: int, M: int) // error (x3): members c,F,M already declared (reported on lines 31-33)
}
module Codatatype refines A {
codatatype Ty = Make(w: int) { // error: wrong number of type parameters
function F<Z>(x: nat): Z // error (x2): wrong number of type parametes, and wrong result type
method M<Z>(x: nat) returns (r: Z) { r := c; } // error (x2): wrong number of type parametes, and wrong out-parameter type
}
}
module Codatatype' refines A {
codatatype Ty<X> = Make(c: int, F: int, M: int) // error (x3): members c,F,M already declared (reported on lines 31-33)
}
module Newtype refines A {
newtype Ty = int { // error: wrong number of type parameters
function F<Z>(x: nat): Z // error (x2): wrong number of type parametes, and wrong result type
method M<Z>(x: nat) returns (r: Z) { r := c; } // error (x2): wrong number of type parametes, and wrong out-parameter type
}
}
module Class refines A {
class Ty { // error: wrong number of type parameters
function F<Z>(x: nat): Z // error (x2): wrong number of type parametes, and wrong result type
method M<Z>(x: nat) returns (r: Z) { r := c; } // error (x2): wrong number of type parametes, and wrong out-parameter type
}
}
module Trait refines A {
trait Ty { // error: wrong number of type parameters
function F<Z>(x: nat): Z // error (x2): wrong number of type parametes, and wrong result type
method M<Z>(x: nat) returns (r: Z) { r := c; } // error (x2): wrong number of type parametes, and wrong out-parameter type
}
}
module TypeSynonym refines A {
type Ty = int // error: not allowed, since the original type has members
}
}
module StartingFromDatatype {
abstract module A {
datatype Ty = Make(w: int) {
const c: nat
function F(x: nat): nat
method M(x: nat) returns (r: nat)
}
}
module OpaqueType refines A {
type Ty ... // error: cannot refine a datatype with an abstract type
}
module OpaqueType' refines A {
type Ty ... { } // error: cannot refine a datatype with an abstract type
}
module Datatype refines A {
datatype Ty ... {
}
}
module Codatatype refines A {
codatatype Ty ... // error: cannot refine a datatype with a codatatype
}
module Newtype refines A {
newtype Ty ... { } // error: cannot refine a datatype with a newtype
}
module Class refines A {
class Ty ... { } // error: cannot refine a datatype with a class
}
module Trait refines A {
trait Ty ... { } // error: cannot refine a datatype with a trait
}
module TypeSynonym refines A {
type Ty = int // error: cannot refine a datatype with a type synonym
}
}
module StartingFromCodatatype {
abstract module A {
codatatype Ty = Make(w: int) {
const c: nat
function F(x: nat): nat
method M(x: nat) returns (r: nat)
}
}
module OpaqueType refines A {
type Ty ... // error: cannot refine a codatatype with an abstract type
}
module Datatype refines A {
datatype Ty ... // error: cannot refine a codatatype with a datatype
}
module Codatatype refines A {
codatatype Ty ... {
}
}
module Newtype refines A {
newtype Ty ... { } // error: cannot refine a codatatype with a newtype
}
module Class refines A {
class Ty ... { } // error: cannot refine a codatatype with a class
}
module Trait refines A {
trait Ty ... { } // error: cannot refine a codatatype with a trait
}
module TypeSynonym refines A {
type Ty = int // error: cannot refine a codatatype with a type synonym
}
}
module StartingFromNewtype {
abstract module A {
newtype Ty = int {
const c: nat
function F(x: nat): nat
method M(x: nat) returns (r: nat)
}
}
module OpaqueType refines A {
type Ty ... // error: cannot refine a newtype with an abstract type
}
module Datatype refines A {
datatype Ty ... // error: cannot refine a newtype with a datatype
}
module Codatatype refines A {
codatatype Ty ... { // error: cannot refine a newtype with a codatatype
}
}
module Class refines A {
class Ty ... { } // error: cannot refine a newtype with a class
}
module Trait refines A {
trait Ty ... { } // error: cannot refine a newtype with a trait
}
module TypeSynonym refines A {
type Ty = int // error: cannot refine a newtype with a type synonym
}
}
module StartingFromClass {
abstract module A {
class Ty {
const c: nat
function F(x: nat): nat
method M(x: nat) returns (r: nat)
}
}
module OpaqueType refines A {
type Ty ... // error: cannot refine a class with an abstract type
}
module Datatype refines A {
datatype Ty ... // error: cannot refine a class with a datatype
}
module Codatatype refines A {
codatatype Ty ... { // error: cannot refine a class with a codatatype
}
}
module Newtype refines A {
newtype Ty ... { } // error: cannot refine a class with a newtype
}
module Trait refines A {
trait Ty ... { } // error: cannot refine a class with a trait
}
module TypeSynonym refines A {
type Ty = int // error: cannot refine a class with a type synonym
}
}
module StartingFromTrait {
abstract module A {
trait Ty {
const c: nat
function F(x: nat): nat
method M(x: nat) returns (r: nat)
}
}
module OpaqueType refines A {
type Ty ... // error: cannot refine a trait with an abstract type
}
module Datatype refines A {
datatype Ty ... // error: cannot refine a trait with a datatype
}
module Codatatype refines A {
codatatype Ty ... { // error: cannot refine a trait with a codatatype
}
}
module Newtype refines A {
newtype Ty ... { } // error: cannot refine a trait with a newtype
}
module Class refines A {
class Ty ... { } // error: cannot refine a trait with a class
}
module TypeSynonym refines A {
type Ty = int // error: cannot refine a trait with a type synonym
}
}