-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcompile.t
283 lines (191 loc) · 5.09 KB
/
compile.t
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
Import compiled files
$ cat >one.ny <<EOF
> axiom A : Type
> EOF
$ cat >two.ny <<EOF
> import "one"
> axiom a0 : A
> EOF
$ narya one.ny
$ narya -v two.ny
→ info[I0004]
○ file loaded: $TESTCASE_ROOT/one.ny (compiled)
→ info[I0001]
○ axiom a0 assumed
Modified files are recompiled
$ touch one.ny
$ narya -v two.ny
→ info[I0003]
○ loading file: $TESTCASE_ROOT/one.ny
→ info[I0001]
○ axiom A assumed
→ info[I0004]
○ file loaded: $TESTCASE_ROOT/one.ny (source)
→ info[I0001]
○ axiom a0 assumed
Files are recompiled if the flags change
$ narya -dtt -v two.ny
→ warning[W2303]
○ file '$TESTCASE_ROOT/one.ny' was compiled with incompatible flags -arity 2 -direction e,refl,Id -internal, recompiling
→ info[I0003]
○ loading file: $TESTCASE_ROOT/one.ny
→ info[I0001]
○ axiom A assumed
→ info[I0004]
○ file loaded: $TESTCASE_ROOT/one.ny (source)
→ info[I0001]
○ axiom a0 assumed
$ narya two.ny
→ warning[W2303]
○ file '$TESTCASE_ROOT/one.ny' was compiled with incompatible flags -arity 1 -direction d -external, recompiling
Requiring a file multiple times
$ cat >three.ny <<EOF
> import "one"
> axiom a1 : A
> EOF
$ narya three.ny
$ cat >four.ny <<EOF
> import "one"
> import "two"
> import "three"
> axiom a2 : Id A a0 a1
$ narya -v four.ny
→ info[I0004]
○ file loaded: $TESTCASE_ROOT/one.ny (compiled)
→ info[I0004]
○ file loaded: $TESTCASE_ROOT/two.ny (compiled)
→ info[I0004]
○ file loaded: $TESTCASE_ROOT/three.ny (compiled)
→ info[I0001]
○ axiom a2 assumed
Files are recompiled if their dependencies need to be
$ touch one.ny
$ narya -v four.ny
→ info[I0003]
○ loading file: $TESTCASE_ROOT/one.ny
→ info[I0001]
○ axiom A assumed
→ info[I0004]
○ file loaded: $TESTCASE_ROOT/one.ny (source)
→ info[I0003]
○ loading file: $TESTCASE_ROOT/two.ny
→ info[I0001]
○ axiom a0 assumed
→ info[I0004]
○ file loaded: $TESTCASE_ROOT/two.ny (source)
→ info[I0003]
○ loading file: $TESTCASE_ROOT/three.ny
→ info[I0001]
○ axiom a1 assumed
→ info[I0004]
○ file loaded: $TESTCASE_ROOT/three.ny (source)
→ info[I0001]
○ axiom a2 assumed
Circular dependency
$ cat >foo.ny <<EOF
> import "bar"
> EOF
$ cat >bar.ny <<EOF
> import "foo"
> EOF
$ narya foo.ny
→ error[E2300]
○ circular imports:
$TESTCASE_ROOT/foo.ny
imports $TESTCASE_ROOT/bar.ny
imports $TESTCASE_ROOT/foo.ny
[1]
Import is relative to the file's directory
$ mkdir subdir
$ cat >subdir/one.ny <<EOF
> axiom A:Type
> EOF
$ cat >subdir/two.ny <<EOF
> import "one"
> axiom a : A
> EOF
$ narya subdir/one.ny
$ narya subdir/two.ny
$ narya -v -e 'import "subdir/two"'
→ info[I0004]
○ file loaded: $TESTCASE_ROOT/subdir/one.ny (compiled)
→ info[I0004]
○ file loaded: $TESTCASE_ROOT/subdir/two.ny (compiled)
A file isn't loaded twice even if referred to in different ways
$ narya -v -e 'import "subdir/one"' -e 'import "subdir/two"'
→ info[I0004]
○ file loaded: $TESTCASE_ROOT/subdir/one.ny (compiled)
→ info[I0004]
○ file loaded: $TESTCASE_ROOT/subdir/two.ny (compiled)
Notations are used from explicitly imported files, but not transitively.
$ cat >n1.ny <<EOF
> axiom A:Type
> axiom f : A -> A -> A
> axiom a:A
> EOF
$ cat >n2.ny <<EOF
> import "n1"
> notation 0 f : x "&" y := f x y
> EOF
$ cat >n3.ny <<EOF
> import "n1"
> import "n2"
> notation 0 f2 : x "%" y := f x y
> EOF
$ narya n1.ny
$ narya n2.ny
$ narya n1.ny n3.ny -e 'echo a % a'
→ warning[E2209]
○ replacing printing notation for f (previous notation will still be parseable)
a % a
: A
$ narya n1.ny n3.ny -e 'echo a & a'
→ warning[E2209]
○ replacing printing notation for f (previous notation will still be parseable)
a
: A
→ error[E0200]
■ command-line exec string
1 | echo a & a
^ parse error
[1]
Quitting in imports quits only that file
$ cat >qone.ny <<EOF
> axiom A : Type
> quit
> axiom B : Type
> EOF
$ narya qone.ny
$ cat >qtwo.ny <<EOF
> import "qone"
> axiom a0 : A
> EOF
$ narya -v qtwo.ny
→ info[I0004]
○ file loaded: $TESTCASE_ROOT/qone.ny (compiled)
→ info[I0001]
○ axiom a0 assumed
Dimensions work in files loaded from source
$ cat >dim.ny <<EOF
> axiom A:Type
> axiom a0:A
> axiom a1:A
> axiom a2 : Id A a0 a1
> EOF
$ narya dim.ny
$ narya -v -e 'import "dim" echo a2'
→ info[I0004]
○ file loaded: $TESTCASE_ROOT/dim.ny (compiled)
a2
: refl A a0 a1
Echos are not re-executed in compiled files
$ cat >echo.ny <<EOF
> axiom A:Type
> echo A
> EOF
$ narya -e 'import "echo"'
A
: Type
$ narya -e 'import "echo"'
→ warning[W2400]
○ not re-executing echo/synth/show commands when loading compiled file $TESTCASE_ROOT/echo.nyo