authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-05-28 20:23:55-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-05-29 04:23:38-04:00
log0c16cd2d0ed78be2d160f9c865cd0a8703348232
treee7ff390d89611797776f2e67151c1157059d6147
parentcdf30c31ea36365859dd81c207aede3c45c4e022

run zig fmt on the codebase

See #1003

102 files changed, 5969 insertions(+), 3599 deletions(-)

std/base64.zig+1
......@@ -81,6 +81,7 @@ pub const Base64Decoder = struct {
8181 /// e.g. 'A' => 0.
8282 /// undefined for any value not in the 64 alphabet chars.
8383 char_to_index: [256]u8,
84
8485 /// true only for the 64 chars in the alphabet, not the pad char.
8586 char_in_alphabet: [256]bool,
8687 pad_char: u8,
std/crypto/blake2.zig+22-226
......@@ -49,16 +49,16 @@ fn Blake2s(comptime out_len: usize) type {
4949 };
5050
5151 const sigma = [10][16]u8{
52 []const u8 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
53 []const u8 { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
54 []const u8 { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
55 []const u8 { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
56 []const u8 { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
57 []const u8 { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 },
58 []const u8 { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 },
59 []const u8 { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 },
60 []const u8 { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 },
61 []const u8 { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 },
52 []const u8{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
53 []const u8{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
54 []const u8{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
55 []const u8{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
56 []const u8{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
57 []const u8{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 },
58 []const u8{ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 },
59 []const u8{ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 },
60 []const u8{ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 },
61 []const u8{ 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 },
6262 };
6363
6464 h: [8]u32,
......@@ -282,222 +282,18 @@ fn Blake2b(comptime out_len: usize) type {
282282 };
283283
284284 const sigma = [12][16]u8{
285 []const u8{
286 0,
287 1,
288 2,
289 3,
290 4,
291 5,
292 6,
293 7,
294 8,
295 9,
296 10,
297 11,
298 12,
299 13,
300 14,
301 15,
302 },
303 []const u8{
304 14,
305 10,
306 4,
307 8,
308 9,
309 15,
310 13,
311 6,
312 1,
313 12,
314 0,
315 2,
316 11,
317 7,
318 5,
319 3,
320 },
321 []const u8{
322 11,
323 8,
324 12,
325 0,
326 5,
327 2,
328 15,
329 13,
330 10,
331 14,
332 3,
333 6,
334 7,
335 1,
336 9,
337 4,
338 },
339 []const u8{
340 7,
341 9,
342 3,
343 1,
344 13,
345 12,
346 11,
347 14,
348 2,
349 6,
350 5,
351 10,
352 4,
353 0,
354 15,
355 8,
356 },
357 []const u8{
358 9,
359 0,
360 5,
361 7,
362 2,
363 4,
364 10,
365 15,
366 14,
367 1,
368 11,
369 12,
370 6,
371 8,
372 3,
373 13,
374 },
375 []const u8{
376 2,
377 12,
378 6,
379 10,
380 0,
381 11,
382 8,
383 3,
384 4,
385 13,
386 7,
387 5,
388 15,
389 14,
390 1,
391 9,
392 },
393 []const u8{
394 12,
395 5,
396 1,
397 15,
398 14,
399 13,
400 4,
401 10,
402 0,
403 7,
404 6,
405 3,
406 9,
407 2,
408 8,
409 11,
410 },
411 []const u8{
412 13,
413 11,
414 7,
415 14,
416 12,
417 1,
418 3,
419 9,
420 5,
421 0,
422 15,
423 4,
424 8,
425 6,
426 2,
427 10,
428 },
429 []const u8{
430 6,
431 15,
432 14,
433 9,
434 11,
435 3,
436 0,
437 8,
438 12,
439 2,
440 13,
441 7,
442 1,
443 4,
444 10,
445 5,
446 },
447 []const u8{
448 10,
449 2,
450 8,
451 4,
452 7,
453 6,
454 1,
455 5,
456 15,
457 11,
458 9,
459 14,
460 3,
461 12,
462 13,
463 0,
464 },
465 []const u8{
466 0,
467 1,
468 2,
469 3,
470 4,
471 5,
472 6,
473 7,
474 8,
475 9,
476 10,
477 11,
478 12,
479 13,
480 14,
481 15,
482 },
483 []const u8{
484 14,
485 10,
486 4,
487 8,
488 9,
489 15,
490 13,
491 6,
492 1,
493 12,
494 0,
495 2,
496 11,
497 7,
498 5,
499 3,
500 },
285 []const u8{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
286 []const u8{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
287 []const u8{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
288 []const u8{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
289 []const u8{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
290 []const u8{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 },
291 []const u8{ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 },
292 []const u8{ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 },
293 []const u8{ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 },
294 []const u8{ 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 },
295 []const u8{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
296 []const u8{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
501297 };
502298
503299 h: [8]u64,
std/fmt/errol/index.zig+1-2
......@@ -98,7 +98,6 @@ pub fn errol3(value: f64, buffer: []u8) FloatDecimal {
9898/// Uncorrected Errol3 double to ASCII conversion.
9999fn errol3u(val: f64, buffer: []u8) FloatDecimal {
100100 // check if in integer or fixed range
101
102101 if (val > 9.007199254740992e15 and val < 3.40282366920938e+38) {
103102 return errolInt(val, buffer);
104103 } else if (val >= 16.0 and val < 9.007199254740992e15) {
......@@ -420,7 +419,7 @@ fn fpprev(val: f64) f64 {
420419 return @bitCast(f64, @bitCast(u64, val) -% 1);
421420}
422421
423pub const c_digits_lut = []u8 {
422pub const c_digits_lut = []u8{
424423 '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6',
425424 '0', '7', '0', '8', '0', '9', '1', '0', '1', '1', '1', '2', '1', '3',
426425 '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9', '2', '0',
std/fmt/errol/lookup.zig+600-600
......@@ -3,604 +3,604 @@ pub const HP = struct {
33 off: f64,
44};
55pub const lookup_table = []HP{
6 HP{.val=1.000000e+308, .off= -1.097906362944045488e+291 },
7 HP{.val=1.000000e+307, .off= 1.396894023974354241e+290 },
8 HP{.val=1.000000e+306, .off= -1.721606459673645508e+289 },
9 HP{.val=1.000000e+305, .off= 6.074644749446353973e+288 },
10 HP{.val=1.000000e+304, .off= 6.074644749446353567e+287 },
11 HP{.val=1.000000e+303, .off= -1.617650767864564452e+284 },
12 HP{.val=1.000000e+302, .off= -7.629703079084895055e+285 },
13 HP{.val=1.000000e+301, .off= -5.250476025520442286e+284 },
14 HP{.val=1.000000e+300, .off= -5.250476025520441956e+283 },
15 HP{.val=1.000000e+299, .off= -5.250476025520441750e+282 },
16 HP{.val=1.000000e+298, .off= 4.043379652465702264e+281 },
17 HP{.val=1.000000e+297, .off= -1.765280146275637946e+280 },
18 HP{.val=1.000000e+296, .off= 1.865132227937699609e+279 },
19 HP{.val=1.000000e+295, .off= 1.865132227937699609e+278 },
20 HP{.val=1.000000e+294, .off= -6.643646774124810287e+277 },
21 HP{.val=1.000000e+293, .off= 7.537651562646039934e+276 },
22 HP{.val=1.000000e+292, .off= -1.325659897835741608e+275 },
23 HP{.val=1.000000e+291, .off= 4.213909764965371606e+274 },
24 HP{.val=1.000000e+290, .off= -6.172783352786715670e+273 },
25 HP{.val=1.000000e+289, .off= -6.172783352786715670e+272 },
26 HP{.val=1.000000e+288, .off= -7.630473539575035471e+270 },
27 HP{.val=1.000000e+287, .off= -7.525217352494018700e+270 },
28 HP{.val=1.000000e+286, .off= -3.298861103408696612e+269 },
29 HP{.val=1.000000e+285, .off= 1.984084207947955778e+268 },
30 HP{.val=1.000000e+284, .off= -7.921438250845767591e+267 },
31 HP{.val=1.000000e+283, .off= 4.460464822646386735e+266 },
32 HP{.val=1.000000e+282, .off= -3.278224598286209647e+265 },
33 HP{.val=1.000000e+281, .off= -3.278224598286209737e+264 },
34 HP{.val=1.000000e+280, .off= -3.278224598286209961e+263 },
35 HP{.val=1.000000e+279, .off= -5.797329227496039232e+262 },
36 HP{.val=1.000000e+278, .off= 3.649313132040821498e+261 },
37 HP{.val=1.000000e+277, .off= -2.867878510995372374e+259 },
38 HP{.val=1.000000e+276, .off= -5.206914080024985409e+259 },
39 HP{.val=1.000000e+275, .off= 4.018322599210230404e+258 },
40 HP{.val=1.000000e+274, .off= 7.862171215558236495e+257 },
41 HP{.val=1.000000e+273, .off= 5.459765830340732821e+256 },
42 HP{.val=1.000000e+272, .off= -6.552261095746788047e+255 },
43 HP{.val=1.000000e+271, .off= 4.709014147460262298e+254 },
44 HP{.val=1.000000e+270, .off= -4.675381888545612729e+253 },
45 HP{.val=1.000000e+269, .off= -4.675381888545612892e+252 },
46 HP{.val=1.000000e+268, .off= 2.656177514583977380e+251 },
47 HP{.val=1.000000e+267, .off= 2.656177514583977190e+250 },
48 HP{.val=1.000000e+266, .off= -3.071603269111014892e+249 },
49 HP{.val=1.000000e+265, .off= -6.651466258920385440e+248 },
50 HP{.val=1.000000e+264, .off= -4.414051890289528972e+247 },
51 HP{.val=1.000000e+263, .off= -1.617283929500958387e+246 },
52 HP{.val=1.000000e+262, .off= -1.617283929500958241e+245 },
53 HP{.val=1.000000e+261, .off= 7.122615947963323868e+244 },
54 HP{.val=1.000000e+260, .off= -6.533477610574617382e+243 },
55 HP{.val=1.000000e+259, .off= 7.122615947963323982e+242 },
56 HP{.val=1.000000e+258, .off= -5.679971763165996225e+241 },
57 HP{.val=1.000000e+257, .off= -3.012765990014054219e+240 },
58 HP{.val=1.000000e+256, .off= -3.012765990014054219e+239 },
59 HP{.val=1.000000e+255, .off= 1.154743030535854616e+238 },
60 HP{.val=1.000000e+254, .off= 6.364129306223240767e+237 },
61 HP{.val=1.000000e+253, .off= 6.364129306223241129e+236 },
62 HP{.val=1.000000e+252, .off= -9.915202805299840595e+235 },
63 HP{.val=1.000000e+251, .off= -4.827911520448877980e+234 },
64 HP{.val=1.000000e+250, .off= 7.890316691678530146e+233 },
65 HP{.val=1.000000e+249, .off= 7.890316691678529484e+232 },
66 HP{.val=1.000000e+248, .off= -4.529828046727141859e+231 },
67 HP{.val=1.000000e+247, .off= 4.785280507077111924e+230 },
68 HP{.val=1.000000e+246, .off= -6.858605185178205305e+229 },
69 HP{.val=1.000000e+245, .off= -4.432795665958347728e+228 },
70 HP{.val=1.000000e+244, .off= -7.465057564983169531e+227 },
71 HP{.val=1.000000e+243, .off= -7.465057564983169741e+226 },
72 HP{.val=1.000000e+242, .off= -5.096102956370027445e+225 },
73 HP{.val=1.000000e+241, .off= -5.096102956370026952e+224 },
74 HP{.val=1.000000e+240, .off= -1.394611380411992474e+223 },
75 HP{.val=1.000000e+239, .off= 9.188208545617793960e+221 },
76 HP{.val=1.000000e+238, .off= -4.864759732872650359e+221 },
77 HP{.val=1.000000e+237, .off= 5.979453868566904629e+220 },
78 HP{.val=1.000000e+236, .off= -5.316601966265964857e+219 },
79 HP{.val=1.000000e+235, .off= -5.316601966265964701e+218 },
80 HP{.val=1.000000e+234, .off= -1.786584517880693123e+217 },
81 HP{.val=1.000000e+233, .off= 2.625937292600896716e+216 },
82 HP{.val=1.000000e+232, .off= -5.647541102052084079e+215 },
83 HP{.val=1.000000e+231, .off= -5.647541102052083888e+214 },
84 HP{.val=1.000000e+230, .off= -9.956644432600511943e+213 },
85 HP{.val=1.000000e+229, .off= 8.161138937705571862e+211 },
86 HP{.val=1.000000e+228, .off= 7.549087847752475275e+211 },
87 HP{.val=1.000000e+227, .off= -9.283347037202319948e+210 },
88 HP{.val=1.000000e+226, .off= 3.866992716668613820e+209 },
89 HP{.val=1.000000e+225, .off= 7.154577655136347262e+208 },
90 HP{.val=1.000000e+224, .off= 3.045096482051680688e+207 },
91 HP{.val=1.000000e+223, .off= -4.660180717482069567e+206 },
92 HP{.val=1.000000e+222, .off= -4.660180717482070101e+205 },
93 HP{.val=1.000000e+221, .off= -4.660180717482069544e+204 },
94 HP{.val=1.000000e+220, .off= 3.562757926310489022e+202 },
95 HP{.val=1.000000e+219, .off= 3.491561111451748149e+202 },
96 HP{.val=1.000000e+218, .off= -8.265758834125874135e+201 },
97 HP{.val=1.000000e+217, .off= 3.981449442517482365e+200 },
98 HP{.val=1.000000e+216, .off= -2.142154695804195936e+199 },
99 HP{.val=1.000000e+215, .off= 9.339603063548950188e+198 },
100 HP{.val=1.000000e+214, .off= 4.555537330485139746e+197 },
101 HP{.val=1.000000e+213, .off= 1.565496247320257804e+196 },
102 HP{.val=1.000000e+212, .off= 9.040598955232462036e+195 },
103 HP{.val=1.000000e+211, .off= 4.368659762787334780e+194 },
104 HP{.val=1.000000e+210, .off= 7.288621758065539072e+193 },
105 HP{.val=1.000000e+209, .off= -7.311188218325485628e+192 },
106 HP{.val=1.000000e+208, .off= 1.813693016918905189e+191 },
107 HP{.val=1.000000e+207, .off= -3.889357755108838992e+190 },
108 HP{.val=1.000000e+206, .off= -3.889357755108838992e+189 },
109 HP{.val=1.000000e+205, .off= -1.661603547285501360e+188 },
110 HP{.val=1.000000e+204, .off= 1.123089212493670643e+187 },
111 HP{.val=1.000000e+203, .off= 1.123089212493670643e+186 },
112 HP{.val=1.000000e+202, .off= 9.825254086803583029e+185 },
113 HP{.val=1.000000e+201, .off= -3.771878529305654999e+184 },
114 HP{.val=1.000000e+200, .off= 3.026687778748963675e+183 },
115 HP{.val=1.000000e+199, .off= -9.720624048853446693e+182 },
116 HP{.val=1.000000e+198, .off= -1.753554156601940139e+181 },
117 HP{.val=1.000000e+197, .off= 4.885670753607648963e+180 },
118 HP{.val=1.000000e+196, .off= 4.885670753607648963e+179 },
119 HP{.val=1.000000e+195, .off= 2.292223523057028076e+178 },
120 HP{.val=1.000000e+194, .off= 5.534032561245303825e+177 },
121 HP{.val=1.000000e+193, .off= -6.622751331960730683e+176 },
122 HP{.val=1.000000e+192, .off= -4.090088020876139692e+175 },
123 HP{.val=1.000000e+191, .off= -7.255917159731877552e+174 },
124 HP{.val=1.000000e+190, .off= -7.255917159731877992e+173 },
125 HP{.val=1.000000e+189, .off= -2.309309130269787104e+172 },
126 HP{.val=1.000000e+188, .off= -2.309309130269787019e+171 },
127 HP{.val=1.000000e+187, .off= 9.284303438781988230e+170 },
128 HP{.val=1.000000e+186, .off= 2.038295583124628364e+169 },
129 HP{.val=1.000000e+185, .off= 2.038295583124628532e+168 },
130 HP{.val=1.000000e+184, .off= -1.735666841696912925e+167 },
131 HP{.val=1.000000e+183, .off= 5.340512704843477241e+166 },
132 HP{.val=1.000000e+182, .off= -6.453119872723839321e+165 },
133 HP{.val=1.000000e+181, .off= 8.288920849235306587e+164 },
134 HP{.val=1.000000e+180, .off= -9.248546019891598293e+162 },
135 HP{.val=1.000000e+179, .off= 1.954450226518486016e+162 },
136 HP{.val=1.000000e+178, .off= -5.243811844750628197e+161 },
137 HP{.val=1.000000e+177, .off= -7.448980502074320639e+159 },
138 HP{.val=1.000000e+176, .off= -7.448980502074319858e+158 },
139 HP{.val=1.000000e+175, .off= 6.284654753766312753e+158 },
140 HP{.val=1.000000e+174, .off= -6.895756753684458388e+157 },
141 HP{.val=1.000000e+173, .off= -1.403918625579970616e+156 },
142 HP{.val=1.000000e+172, .off= -8.268716285710580522e+155 },
143 HP{.val=1.000000e+171, .off= 4.602779327034313170e+154 },
144 HP{.val=1.000000e+170, .off= -3.441905430931244940e+153 },
145 HP{.val=1.000000e+169, .off= 6.613950516525702884e+152 },
146 HP{.val=1.000000e+168, .off= 6.613950516525702652e+151 },
147 HP{.val=1.000000e+167, .off= -3.860899428741951187e+150 },
148 HP{.val=1.000000e+166, .off= 5.959272394946474605e+149 },
149 HP{.val=1.000000e+165, .off= 1.005101065481665103e+149 },
150 HP{.val=1.000000e+164, .off= -1.783349948587918355e+146 },
151 HP{.val=1.000000e+163, .off= 6.215006036188360099e+146 },
152 HP{.val=1.000000e+162, .off= 6.215006036188360099e+145 },
153 HP{.val=1.000000e+161, .off= -3.774589324822814903e+144 },
154 HP{.val=1.000000e+160, .off= -6.528407745068226929e+142 },
155 HP{.val=1.000000e+159, .off= 7.151530601283157561e+142 },
156 HP{.val=1.000000e+158, .off= 4.712664546348788765e+141 },
157 HP{.val=1.000000e+157, .off= 1.664081977680827856e+140 },
158 HP{.val=1.000000e+156, .off= 1.664081977680827750e+139 },
159 HP{.val=1.000000e+155, .off= -7.176231540910168265e+137 },
160 HP{.val=1.000000e+154, .off= -3.694754568805822650e+137 },
161 HP{.val=1.000000e+153, .off= 2.665969958768462622e+134 },
162 HP{.val=1.000000e+152, .off= -4.625108135904199522e+135 },
163 HP{.val=1.000000e+151, .off= -1.717753238721771919e+134 },
164 HP{.val=1.000000e+150, .off= 1.916440382756262433e+133 },
165 HP{.val=1.000000e+149, .off= -4.897672657515052040e+132 },
166 HP{.val=1.000000e+148, .off= -4.897672657515052198e+131 },
167 HP{.val=1.000000e+147, .off= 2.200361759434233991e+130 },
168 HP{.val=1.000000e+146, .off= 6.636633270027537273e+129 },
169 HP{.val=1.000000e+145, .off= 1.091293881785907977e+128 },
170 HP{.val=1.000000e+144, .off= -2.374543235865110597e+127 },
171 HP{.val=1.000000e+143, .off= -2.374543235865110537e+126 },
172 HP{.val=1.000000e+142, .off= -5.082228484029969099e+125 },
173 HP{.val=1.000000e+141, .off= -1.697621923823895943e+124 },
174 HP{.val=1.000000e+140, .off= -5.928380124081487212e+123 },
175 HP{.val=1.000000e+139, .off= -3.284156248920492522e+122 },
176 HP{.val=1.000000e+138, .off= -3.284156248920492706e+121 },
177 HP{.val=1.000000e+137, .off= -3.284156248920492476e+120 },
178 HP{.val=1.000000e+136, .off= -5.866406127007401066e+119 },
179 HP{.val=1.000000e+135, .off= 3.817030915818506056e+118 },
180 HP{.val=1.000000e+134, .off= 7.851796350329300951e+117 },
181 HP{.val=1.000000e+133, .off= -2.235117235947686077e+116 },
182 HP{.val=1.000000e+132, .off= 9.170432597638723691e+114 },
183 HP{.val=1.000000e+131, .off= 8.797444499042767883e+114 },
184 HP{.val=1.000000e+130, .off= -5.978307824605161274e+113 },
185 HP{.val=1.000000e+129, .off= 1.782556435814758516e+111 },
186 HP{.val=1.000000e+128, .off= -7.517448691651820362e+111 },
187 HP{.val=1.000000e+127, .off= 4.507089332150205498e+110 },
188 HP{.val=1.000000e+126, .off= 7.513223838100711695e+109 },
189 HP{.val=1.000000e+125, .off= 7.513223838100712113e+108 },
190 HP{.val=1.000000e+124, .off= 5.164681255326878494e+107 },
191 HP{.val=1.000000e+123, .off= 2.229003026859587122e+106 },
192 HP{.val=1.000000e+122, .off= -1.440594758724527399e+105 },
193 HP{.val=1.000000e+121, .off= -3.734093374714598783e+104 },
194 HP{.val=1.000000e+120, .off= 1.999653165260579757e+103 },
195 HP{.val=1.000000e+119, .off= 5.583244752745066693e+102 },
196 HP{.val=1.000000e+118, .off= 3.343500010567262234e+101 },
197 HP{.val=1.000000e+117, .off= -5.055542772599503556e+100 },
198 HP{.val=1.000000e+116, .off= -1.555941612946684331e+99 },
199 HP{.val=1.000000e+115, .off= -1.555941612946684331e+98 },
200 HP{.val=1.000000e+114, .off= -1.555941612946684293e+97 },
201 HP{.val=1.000000e+113, .off= -1.555941612946684246e+96 },
202 HP{.val=1.000000e+112, .off= 6.988006530736955847e+95 },
203 HP{.val=1.000000e+111, .off= 4.318022735835818244e+94 },
204 HP{.val=1.000000e+110, .off= -2.356936751417025578e+93 },
205 HP{.val=1.000000e+109, .off= 1.814912928116001926e+92 },
206 HP{.val=1.000000e+108, .off= -3.399899171300282744e+91 },
207 HP{.val=1.000000e+107, .off= 3.118615952970072913e+90 },
208 HP{.val=1.000000e+106, .off= -9.103599905036843605e+89 },
209 HP{.val=1.000000e+105, .off= 6.174169917471802325e+88 },
210 HP{.val=1.000000e+104, .off= -1.915675085734668657e+86 },
211 HP{.val=1.000000e+103, .off= -1.915675085734668864e+85 },
212 HP{.val=1.000000e+102, .off= 2.295048673475466221e+85 },
213 HP{.val=1.000000e+101, .off= 2.295048673475466135e+84 },
214 HP{.val=1.000000e+100, .off= -1.590289110975991792e+83 },
215 HP{.val=1.000000e+99, .off= 3.266383119588331155e+82 },
216 HP{.val=1.000000e+98, .off= 2.309629754856292029e+80 },
217 HP{.val=1.000000e+97, .off= -7.357587384771124533e+80 },
218 HP{.val=1.000000e+96, .off= -4.986165397190889509e+79 },
219 HP{.val=1.000000e+95, .off= -2.021887912715594741e+78 },
220 HP{.val=1.000000e+94, .off= -2.021887912715594638e+77 },
221 HP{.val=1.000000e+93, .off= -4.337729697461918675e+76 },
222 HP{.val=1.000000e+92, .off= -4.337729697461918997e+75 },
223 HP{.val=1.000000e+91, .off= -7.956232486128049702e+74 },
224 HP{.val=1.000000e+90, .off= 3.351588728453609882e+73 },
225 HP{.val=1.000000e+89, .off= 5.246334248081951113e+71 },
226 HP{.val=1.000000e+88, .off= 4.058327554364963672e+71 },
227 HP{.val=1.000000e+87, .off= 4.058327554364963918e+70 },
228 HP{.val=1.000000e+86, .off= -1.463069523067487266e+69 },
229 HP{.val=1.000000e+85, .off= -1.463069523067487314e+68 },
230 HP{.val=1.000000e+84, .off= -5.776660989811589441e+67 },
231 HP{.val=1.000000e+83, .off= -3.080666323096525761e+66 },
232 HP{.val=1.000000e+82, .off= 3.659320343691134468e+65 },
233 HP{.val=1.000000e+81, .off= 7.871812010433421235e+64 },
234 HP{.val=1.000000e+80, .off= -2.660986470836727449e+61 },
235 HP{.val=1.000000e+79, .off= 3.264399249934044627e+62 },
236 HP{.val=1.000000e+78, .off= -8.493621433689703070e+60 },
237 HP{.val=1.000000e+77, .off= 1.721738727445414063e+60 },
238 HP{.val=1.000000e+76, .off= -4.706013449590547218e+59 },
239 HP{.val=1.000000e+75, .off= 7.346021882351880518e+58 },
240 HP{.val=1.000000e+74, .off= 4.835181188197207515e+57 },
241 HP{.val=1.000000e+73, .off= 1.696630320503867482e+56 },
242 HP{.val=1.000000e+72, .off= 5.619818905120542959e+55 },
243 HP{.val=1.000000e+71, .off= -4.188152556421145598e+54 },
244 HP{.val=1.000000e+70, .off= -7.253143638152923145e+53 },
245 HP{.val=1.000000e+69, .off= -7.253143638152923145e+52 },
246 HP{.val=1.000000e+68, .off= 4.719477774861832896e+51 },
247 HP{.val=1.000000e+67, .off= 1.726322421608144052e+50 },
248 HP{.val=1.000000e+66, .off= 5.467766613175255107e+49 },
249 HP{.val=1.000000e+65, .off= 7.909613737163661911e+47 },
250 HP{.val=1.000000e+64, .off= -2.132041900945439564e+47 },
251 HP{.val=1.000000e+63, .off= -5.785795994272697265e+46 },
252 HP{.val=1.000000e+62, .off= -3.502199685943161329e+45 },
253 HP{.val=1.000000e+61, .off= 5.061286470292598274e+44 },
254 HP{.val=1.000000e+60, .off= 5.061286470292598472e+43 },
255 HP{.val=1.000000e+59, .off= 2.831211950439536034e+42 },
256 HP{.val=1.000000e+58, .off= 5.618805100255863927e+41 },
257 HP{.val=1.000000e+57, .off= -4.834669211555366251e+40 },
258 HP{.val=1.000000e+56, .off= -9.190283508143378583e+39 },
259 HP{.val=1.000000e+55, .off= -1.023506702040855158e+38 },
260 HP{.val=1.000000e+54, .off= -7.829154040459624616e+37 },
261 HP{.val=1.000000e+53, .off= 6.779051325638372659e+35 },
262 HP{.val=1.000000e+52, .off= 6.779051325638372290e+34 },
263 HP{.val=1.000000e+51, .off= 6.779051325638371598e+33 },
264 HP{.val=1.000000e+50, .off= -7.629769841091887392e+33 },
265 HP{.val=1.000000e+49, .off= 5.350972305245182400e+32 },
266 HP{.val=1.000000e+48, .off= -4.384584304507619764e+31 },
267 HP{.val=1.000000e+47, .off= -4.384584304507619876e+30 },
268 HP{.val=1.000000e+46, .off= 6.860180964052978705e+28 },
269 HP{.val=1.000000e+45, .off= 7.024271097546444878e+28 },
270 HP{.val=1.000000e+44, .off= -8.821361405306422641e+27 },
271 HP{.val=1.000000e+43, .off= -1.393721169594140991e+26 },
272 HP{.val=1.000000e+42, .off= -4.488571267807591679e+25 },
273 HP{.val=1.000000e+41, .off= -6.200086450407783195e+23 },
274 HP{.val=1.000000e+40, .off= -3.037860284270036669e+23 },
275 HP{.val=1.000000e+39, .off= 6.029083362839682141e+22 },
276 HP{.val=1.000000e+38, .off= 2.251190176543965970e+21 },
277 HP{.val=1.000000e+37, .off= 4.612373417978788577e+20 },
278 HP{.val=1.000000e+36, .off= -4.242063737401796198e+19 },
279 HP{.val=1.000000e+35, .off= 3.136633892082024448e+18 },
280 HP{.val=1.000000e+34, .off= 5.442476901295718400e+17 },
281 HP{.val=1.000000e+33, .off= 5.442476901295718400e+16 },
282 HP{.val=1.000000e+32, .off= -5.366162204393472000e+15 },
283 HP{.val=1.000000e+31, .off= 3.641037050347520000e+14 },
284 HP{.val=1.000000e+30, .off= -1.988462483865600000e+13 },
285 HP{.val=1.000000e+29, .off= 8.566849142784000000e+12 },
286 HP{.val=1.000000e+28, .off= 4.168802631680000000e+11 },
287 HP{.val=1.000000e+27, .off= -1.328755507200000000e+10 },
288 HP{.val=1.000000e+26, .off= -4.764729344000000000e+09 },
289 HP{.val=1.000000e+25, .off= -9.059696640000000000e+08 },
290 HP{.val=1.000000e+24, .off= 1.677721600000000000e+07 },
291 HP{.val=1.000000e+23, .off= 8.388608000000000000e+06 },
292 HP{.val=1.000000e+22, .off= 0.000000000000000000e+00 },
293 HP{.val=1.000000e+21, .off= 0.000000000000000000e+00 },
294 HP{.val=1.000000e+20, .off= 0.000000000000000000e+00 },
295 HP{.val=1.000000e+19, .off= 0.000000000000000000e+00 },
296 HP{.val=1.000000e+18, .off= 0.000000000000000000e+00 },
297 HP{.val=1.000000e+17, .off= 0.000000000000000000e+00 },
298 HP{.val=1.000000e+16, .off= 0.000000000000000000e+00 },
299 HP{.val=1.000000e+15, .off= 0.000000000000000000e+00 },
300 HP{.val=1.000000e+14, .off= 0.000000000000000000e+00 },
301 HP{.val=1.000000e+13, .off= 0.000000000000000000e+00 },
302 HP{.val=1.000000e+12, .off= 0.000000000000000000e+00 },
303 HP{.val=1.000000e+11, .off= 0.000000000000000000e+00 },
304 HP{.val=1.000000e+10, .off= 0.000000000000000000e+00 },
305 HP{.val=1.000000e+09, .off= 0.000000000000000000e+00 },
306 HP{.val=1.000000e+08, .off= 0.000000000000000000e+00 },
307 HP{.val=1.000000e+07, .off= 0.000000000000000000e+00 },
308 HP{.val=1.000000e+06, .off= 0.000000000000000000e+00 },
309 HP{.val=1.000000e+05, .off= 0.000000000000000000e+00 },
310 HP{.val=1.000000e+04, .off= 0.000000000000000000e+00 },
311 HP{.val=1.000000e+03, .off= 0.000000000000000000e+00 },
312 HP{.val=1.000000e+02, .off= 0.000000000000000000e+00 },
313 HP{.val=1.000000e+01, .off= 0.000000000000000000e+00 },
314 HP{.val=1.000000e+00, .off= 0.000000000000000000e+00 },
315 HP{.val=1.000000e-01, .off= -5.551115123125783010e-18 },
316 HP{.val=1.000000e-02, .off= -2.081668171172168436e-19 },
317 HP{.val=1.000000e-03, .off= -2.081668171172168557e-20 },
318 HP{.val=1.000000e-04, .off= -4.792173602385929943e-21 },
319 HP{.val=1.000000e-05, .off= -8.180305391403130547e-22 },
320 HP{.val=1.000000e-06, .off= 4.525188817411374069e-23 },
321 HP{.val=1.000000e-07, .off= 4.525188817411373922e-24 },
322 HP{.val=1.000000e-08, .off= -2.092256083012847109e-25 },
323 HP{.val=1.000000e-09, .off= -6.228159145777985254e-26 },
324 HP{.val=1.000000e-10, .off= -3.643219731549774344e-27 },
325 HP{.val=1.000000e-11, .off= 6.050303071806019080e-28 },
326 HP{.val=1.000000e-12, .off= 2.011335237074438524e-29 },
327 HP{.val=1.000000e-13, .off= -3.037374556340037101e-30 },
328 HP{.val=1.000000e-14, .off= 1.180690645440101289e-32 },
329 HP{.val=1.000000e-15, .off= -7.770539987666107583e-32 },
330 HP{.val=1.000000e-16, .off= 2.090221327596539779e-33 },
331 HP{.val=1.000000e-17, .off= -7.154242405462192144e-34 },
332 HP{.val=1.000000e-18, .off= -7.154242405462192572e-35 },
333 HP{.val=1.000000e-19, .off= 2.475407316473986894e-36 },
334 HP{.val=1.000000e-20, .off= 5.484672854579042914e-37 },
335 HP{.val=1.000000e-21, .off= 9.246254777210362522e-38 },
336 HP{.val=1.000000e-22, .off= -4.859677432657087182e-39 },
337 HP{.val=1.000000e-23, .off= 3.956530198510069291e-40 },
338 HP{.val=1.000000e-24, .off= 7.629950044829717753e-41 },
339 HP{.val=1.000000e-25, .off= -3.849486974919183692e-42 },
340 HP{.val=1.000000e-26, .off= -3.849486974919184170e-43 },
341 HP{.val=1.000000e-27, .off= -3.849486974919184070e-44 },
342 HP{.val=1.000000e-28, .off= 2.876745653839937870e-45 },
343 HP{.val=1.000000e-29, .off= 5.679342582489572168e-46 },
344 HP{.val=1.000000e-30, .off= -8.333642060758598930e-47 },
345 HP{.val=1.000000e-31, .off= -8.333642060758597958e-48 },
346 HP{.val=1.000000e-32, .off= -5.596730997624190224e-49 },
347 HP{.val=1.000000e-33, .off= -5.596730997624190604e-50 },
348 HP{.val=1.000000e-34, .off= 7.232539610818348498e-51 },
349 HP{.val=1.000000e-35, .off= -7.857545194582380514e-53 },
350 HP{.val=1.000000e-36, .off= 5.896157255772251528e-53 },
351 HP{.val=1.000000e-37, .off= -6.632427322784915796e-54 },
352 HP{.val=1.000000e-38, .off= 3.808059826012723592e-55 },
353 HP{.val=1.000000e-39, .off= 7.070712060011985131e-56 },
354 HP{.val=1.000000e-40, .off= 7.070712060011985584e-57 },
355 HP{.val=1.000000e-41, .off= -5.761291134237854167e-59 },
356 HP{.val=1.000000e-42, .off= -3.762312935688689794e-59 },
357 HP{.val=1.000000e-43, .off= -7.745042713519821150e-60 },
358 HP{.val=1.000000e-44, .off= 4.700987842202462817e-61 },
359 HP{.val=1.000000e-45, .off= 1.589480203271891964e-62 },
360 HP{.val=1.000000e-46, .off= -2.299904345391321765e-63 },
361 HP{.val=1.000000e-47, .off= 2.561826340437695261e-64 },
362 HP{.val=1.000000e-48, .off= 2.561826340437695345e-65 },
363 HP{.val=1.000000e-49, .off= 6.360053438741614633e-66 },
364 HP{.val=1.000000e-50, .off= -7.616223705782342295e-68 },
365 HP{.val=1.000000e-51, .off= -7.616223705782343324e-69 },
366 HP{.val=1.000000e-52, .off= -7.616223705782342295e-70 },
367 HP{.val=1.000000e-53, .off= -3.079876214757872338e-70 },
368 HP{.val=1.000000e-54, .off= -3.079876214757872821e-71 },
369 HP{.val=1.000000e-55, .off= 5.423954167728123147e-73 },
370 HP{.val=1.000000e-56, .off= -3.985444122640543680e-73 },
371 HP{.val=1.000000e-57, .off= 4.504255013759498850e-74 },
372 HP{.val=1.000000e-58, .off= -2.570494266573869991e-75 },
373 HP{.val=1.000000e-59, .off= -2.570494266573869930e-76 },
374 HP{.val=1.000000e-60, .off= 2.956653608686574324e-77 },
375 HP{.val=1.000000e-61, .off= -3.952281235388981376e-78 },
376 HP{.val=1.000000e-62, .off= -3.952281235388981376e-79 },
377 HP{.val=1.000000e-63, .off= -6.651083908855995172e-80 },
378 HP{.val=1.000000e-64, .off= 3.469426116645307030e-81 },
379 HP{.val=1.000000e-65, .off= 7.686305293937516319e-82 },
380 HP{.val=1.000000e-66, .off= 2.415206322322254927e-83 },
381 HP{.val=1.000000e-67, .off= 5.709643179581793251e-84 },
382 HP{.val=1.000000e-68, .off= -6.644495035141475923e-85 },
383 HP{.val=1.000000e-69, .off= 3.650620143794581913e-86 },
384 HP{.val=1.000000e-70, .off= 4.333966503770636492e-88 },
385 HP{.val=1.000000e-71, .off= 8.476455383920859113e-88 },
386 HP{.val=1.000000e-72, .off= 3.449543675455986564e-89 },
387 HP{.val=1.000000e-73, .off= 3.077238576654418974e-91 },
388 HP{.val=1.000000e-74, .off= 4.234998629903623140e-91 },
389 HP{.val=1.000000e-75, .off= 4.234998629903623412e-92 },
390 HP{.val=1.000000e-76, .off= 7.303182045714702338e-93 },
391 HP{.val=1.000000e-77, .off= 7.303182045714701699e-94 },
392 HP{.val=1.000000e-78, .off= 1.121271649074855759e-96 },
393 HP{.val=1.000000e-79, .off= 1.121271649074855863e-97 },
394 HP{.val=1.000000e-80, .off= 3.857468248661243988e-97 },
395 HP{.val=1.000000e-81, .off= 3.857468248661244248e-98 },
396 HP{.val=1.000000e-82, .off= 3.857468248661244410e-99 },
397 HP{.val=1.000000e-83, .off= -3.457651055545315679e-100 },
398 HP{.val=1.000000e-84, .off= -3.457651055545315933e-101 },
399 HP{.val=1.000000e-85, .off= 2.257285900866059216e-102 },
400 HP{.val=1.000000e-86, .off= -8.458220892405268345e-103 },
401 HP{.val=1.000000e-87, .off= -1.761029146610688867e-104 },
402 HP{.val=1.000000e-88, .off= 6.610460535632536565e-105 },
403 HP{.val=1.000000e-89, .off= -3.853901567171494935e-106 },
404 HP{.val=1.000000e-90, .off= 5.062493089968513723e-108 },
405 HP{.val=1.000000e-91, .off= -2.218844988608365240e-108 },
406 HP{.val=1.000000e-92, .off= 1.187522883398155383e-109 },
407 HP{.val=1.000000e-93, .off= 9.703442563414457296e-110 },
408 HP{.val=1.000000e-94, .off= 4.380992763404268896e-111 },
409 HP{.val=1.000000e-95, .off= 1.054461638397900823e-112 },
410 HP{.val=1.000000e-96, .off= 9.370789450913819736e-113 },
411 HP{.val=1.000000e-97, .off= -3.623472756142303998e-114 },
412 HP{.val=1.000000e-98, .off= 6.122223899149788839e-115 },
413 HP{.val=1.000000e-99, .off= -1.999189980260288281e-116 },
414 HP{.val=1.000000e-100, .off= -1.999189980260288281e-117 },
415 HP{.val=1.000000e-101, .off= -5.171617276904849634e-118 },
416 HP{.val=1.000000e-102, .off= 6.724985085512256320e-119 },
417 HP{.val=1.000000e-103, .off= 4.246526260008692213e-120 },
418 HP{.val=1.000000e-104, .off= 7.344599791888147003e-121 },
419 HP{.val=1.000000e-105, .off= 3.472007877038828407e-122 },
420 HP{.val=1.000000e-106, .off= 5.892377823819652194e-123 },
421 HP{.val=1.000000e-107, .off= -1.585470431324073925e-125 },
422 HP{.val=1.000000e-108, .off= -3.940375084977444795e-125 },
423 HP{.val=1.000000e-109, .off= 7.869099673288519908e-127 },
424 HP{.val=1.000000e-110, .off= -5.122196348054018581e-127 },
425 HP{.val=1.000000e-111, .off= -8.815387795168313713e-128 },
426 HP{.val=1.000000e-112, .off= 5.034080131510290214e-129 },
427 HP{.val=1.000000e-113, .off= 2.148774313452247863e-130 },
428 HP{.val=1.000000e-114, .off= -5.064490231692858416e-131 },
429 HP{.val=1.000000e-115, .off= -5.064490231692858166e-132 },
430 HP{.val=1.000000e-116, .off= 5.708726942017560559e-134 },
431 HP{.val=1.000000e-117, .off= -2.951229134482377772e-134 },
432 HP{.val=1.000000e-118, .off= 1.451398151372789513e-135 },
433 HP{.val=1.000000e-119, .off= -1.300243902286690040e-136 },
434 HP{.val=1.000000e-120, .off= 2.139308664787659449e-137 },
435 HP{.val=1.000000e-121, .off= 2.139308664787659329e-138 },
436 HP{.val=1.000000e-122, .off= -5.922142664292847471e-139 },
437 HP{.val=1.000000e-123, .off= -5.922142664292846912e-140 },
438 HP{.val=1.000000e-124, .off= 6.673875037395443799e-141 },
439 HP{.val=1.000000e-125, .off= -1.198636026159737932e-142 },
440 HP{.val=1.000000e-126, .off= 5.361789860136246995e-143 },
441 HP{.val=1.000000e-127, .off= -2.838742497733733936e-144 },
442 HP{.val=1.000000e-128, .off= -5.401408859568103261e-145 },
443 HP{.val=1.000000e-129, .off= 7.411922949603743011e-146 },
444 HP{.val=1.000000e-130, .off= -8.604741811861064385e-147 },
445 HP{.val=1.000000e-131, .off= 1.405673664054439890e-148 },
446 HP{.val=1.000000e-132, .off= 1.405673664054439933e-149 },
447 HP{.val=1.000000e-133, .off= -6.414963426504548053e-150 },
448 HP{.val=1.000000e-134, .off= -3.971014335704864578e-151 },
449 HP{.val=1.000000e-135, .off= -3.971014335704864748e-152 },
450 HP{.val=1.000000e-136, .off= -1.523438813303585576e-154 },
451 HP{.val=1.000000e-137, .off= 2.234325152653707766e-154 },
452 HP{.val=1.000000e-138, .off= -6.715683724786540160e-155 },
453 HP{.val=1.000000e-139, .off= -2.986513359186437306e-156 },
454 HP{.val=1.000000e-140, .off= 1.674949597813692102e-157 },
455 HP{.val=1.000000e-141, .off= -4.151879098436469092e-158 },
456 HP{.val=1.000000e-142, .off= -4.151879098436469295e-159 },
457 HP{.val=1.000000e-143, .off= 4.952540739454407825e-160 },
458 HP{.val=1.000000e-144, .off= 4.952540739454407667e-161 },
459 HP{.val=1.000000e-145, .off= 8.508954738630531443e-162 },
460 HP{.val=1.000000e-146, .off= -2.604839008794855481e-163 },
461 HP{.val=1.000000e-147, .off= 2.952057864917838382e-164 },
462 HP{.val=1.000000e-148, .off= 6.425118410988271757e-165 },
463 HP{.val=1.000000e-149, .off= 2.083792728400229858e-166 },
464 HP{.val=1.000000e-150, .off= -6.295358232172964237e-168 },
465 HP{.val=1.000000e-151, .off= 6.153785555826519421e-168 },
466 HP{.val=1.000000e-152, .off= -6.564942029880634994e-169 },
467 HP{.val=1.000000e-153, .off= -3.915207116191644540e-170 },
468 HP{.val=1.000000e-154, .off= 2.709130168030831503e-171 },
469 HP{.val=1.000000e-155, .off= -1.431080634608215966e-172 },
470 HP{.val=1.000000e-156, .off= -4.018712386257620994e-173 },
471 HP{.val=1.000000e-157, .off= 5.684906682427646782e-174 },
472 HP{.val=1.000000e-158, .off= -6.444617153428937489e-175 },
473 HP{.val=1.000000e-159, .off= 1.136335243981427681e-176 },
474 HP{.val=1.000000e-160, .off= 1.136335243981427725e-177 },
475 HP{.val=1.000000e-161, .off= -2.812077463003137395e-178 },
476 HP{.val=1.000000e-162, .off= 4.591196362592922204e-179 },
477 HP{.val=1.000000e-163, .off= 7.675893789924613703e-180 },
478 HP{.val=1.000000e-164, .off= 3.820022005759999543e-181 },
479 HP{.val=1.000000e-165, .off= -9.998177244457686588e-183 },
480 HP{.val=1.000000e-166, .off= -4.012217555824373639e-183 },
481 HP{.val=1.000000e-167, .off= -2.467177666011174334e-185 },
482 HP{.val=1.000000e-168, .off= -4.953592503130188139e-185 },
483 HP{.val=1.000000e-169, .off= -2.011795792799518887e-186 },
484 HP{.val=1.000000e-170, .off= 1.665450095113817423e-187 },
485 HP{.val=1.000000e-171, .off= 1.665450095113817487e-188 },
486 HP{.val=1.000000e-172, .off= -4.080246604750770577e-189 },
487 HP{.val=1.000000e-173, .off= -4.080246604750770677e-190 },
488 HP{.val=1.000000e-174, .off= 4.085789420184387951e-192 },
489 HP{.val=1.000000e-175, .off= 4.085789420184388146e-193 },
490 HP{.val=1.000000e-176, .off= 4.085789420184388146e-194 },
491 HP{.val=1.000000e-177, .off= 4.792197640035244894e-194 },
492 HP{.val=1.000000e-178, .off= 4.792197640035244742e-195 },
493 HP{.val=1.000000e-179, .off= -2.057206575616014662e-196 },
494 HP{.val=1.000000e-180, .off= -2.057206575616014662e-197 },
495 HP{.val=1.000000e-181, .off= -4.732755097354788053e-198 },
496 HP{.val=1.000000e-182, .off= -4.732755097354787867e-199 },
497 HP{.val=1.000000e-183, .off= -5.522105321379546765e-201 },
498 HP{.val=1.000000e-184, .off= -5.777891238658996019e-201 },
499 HP{.val=1.000000e-185, .off= 7.542096444923057046e-203 },
500 HP{.val=1.000000e-186, .off= 8.919335748431433483e-203 },
501 HP{.val=1.000000e-187, .off= -1.287071881492476028e-204 },
502 HP{.val=1.000000e-188, .off= 5.091932887209967018e-205 },
503 HP{.val=1.000000e-189, .off= -6.868701054107114024e-206 },
504 HP{.val=1.000000e-190, .off= -1.885103578558330118e-207 },
505 HP{.val=1.000000e-191, .off= -1.885103578558330205e-208 },
506 HP{.val=1.000000e-192, .off= -9.671974634103305058e-209 },
507 HP{.val=1.000000e-193, .off= -4.805180224387695640e-210 },
508 HP{.val=1.000000e-194, .off= -1.763433718315439838e-211 },
509 HP{.val=1.000000e-195, .off= -9.367799983496079132e-212 },
510 HP{.val=1.000000e-196, .off= -4.615071067758179837e-213 },
511 HP{.val=1.000000e-197, .off= 1.325840076914194777e-214 },
512 HP{.val=1.000000e-198, .off= 8.751979007754662425e-215 },
513 HP{.val=1.000000e-199, .off= 1.789973760091724198e-216 },
514 HP{.val=1.000000e-200, .off= 1.789973760091724077e-217 },
515 HP{.val=1.000000e-201, .off= 5.416018159916171171e-218 },
516 HP{.val=1.000000e-202, .off= -3.649092839644947067e-219 },
517 HP{.val=1.000000e-203, .off= -3.649092839644947067e-220 },
518 HP{.val=1.000000e-204, .off= -1.080338554413850956e-222 },
519 HP{.val=1.000000e-205, .off= -1.080338554413850841e-223 },
520 HP{.val=1.000000e-206, .off= -2.874486186850417807e-223 },
521 HP{.val=1.000000e-207, .off= 7.499710055933455072e-224 },
522 HP{.val=1.000000e-208, .off= -9.790617015372999087e-225 },
523 HP{.val=1.000000e-209, .off= -4.387389805589732612e-226 },
524 HP{.val=1.000000e-210, .off= -4.387389805589732612e-227 },
525 HP{.val=1.000000e-211, .off= -8.608661063232909897e-228 },
526 HP{.val=1.000000e-212, .off= 4.582811616902018972e-229 },
527 HP{.val=1.000000e-213, .off= 4.582811616902019155e-230 },
528 HP{.val=1.000000e-214, .off= 8.705146829444184930e-231 },
529 HP{.val=1.000000e-215, .off= -4.177150709750081830e-232 },
530 HP{.val=1.000000e-216, .off= -4.177150709750082366e-233 },
531 HP{.val=1.000000e-217, .off= -8.202868690748290237e-234 },
532 HP{.val=1.000000e-218, .off= -3.170721214500530119e-235 },
533 HP{.val=1.000000e-219, .off= -3.170721214500529857e-236 },
534 HP{.val=1.000000e-220, .off= 7.606440013180328441e-238 },
535 HP{.val=1.000000e-221, .off= -1.696459258568569049e-238 },
536 HP{.val=1.000000e-222, .off= -4.767838333426821244e-239 },
537 HP{.val=1.000000e-223, .off= 2.910609353718809138e-240 },
538 HP{.val=1.000000e-224, .off= -1.888420450747209784e-241 },
539 HP{.val=1.000000e-225, .off= 4.110366804835314035e-242 },
540 HP{.val=1.000000e-226, .off= 7.859608839574391006e-243 },
541 HP{.val=1.000000e-227, .off= 5.516332567862468419e-244 },
542 HP{.val=1.000000e-228, .off= -3.270953451057244613e-245 },
543 HP{.val=1.000000e-229, .off= -6.932322625607124670e-246 },
544 HP{.val=1.000000e-230, .off= -4.643966891513449762e-247 },
545 HP{.val=1.000000e-231, .off= 1.076922443720738305e-248 },
546 HP{.val=1.000000e-232, .off= -2.498633390800628939e-249 },
547 HP{.val=1.000000e-233, .off= 4.205533798926934891e-250 },
548 HP{.val=1.000000e-234, .off= 4.205533798926934891e-251 },
549 HP{.val=1.000000e-235, .off= 4.205533798926934697e-252 },
550 HP{.val=1.000000e-236, .off= -4.523850562697497656e-253 },
551 HP{.val=1.000000e-237, .off= 9.320146633177728298e-255 },
552 HP{.val=1.000000e-238, .off= 9.320146633177728062e-256 },
553 HP{.val=1.000000e-239, .off= -7.592774752331086440e-256 },
554 HP{.val=1.000000e-240, .off= 3.063212017229987840e-257 },
555 HP{.val=1.000000e-241, .off= 3.063212017229987562e-258 },
556 HP{.val=1.000000e-242, .off= 3.063212017229987562e-259 },
557 HP{.val=1.000000e-243, .off= 4.616527473176159842e-261 },
558 HP{.val=1.000000e-244, .off= 6.965550922098544975e-261 },
559 HP{.val=1.000000e-245, .off= 6.965550922098544749e-262 },
560 HP{.val=1.000000e-246, .off= 4.424965697574744679e-263 },
561 HP{.val=1.000000e-247, .off= -1.926497363734756420e-264 },
562 HP{.val=1.000000e-248, .off= 2.043167049583681740e-265 },
563 HP{.val=1.000000e-249, .off= -5.399953725388390154e-266 },
564 HP{.val=1.000000e-250, .off= -5.399953725388389982e-267 },
565 HP{.val=1.000000e-251, .off= -1.523328321757102663e-268 },
566 HP{.val=1.000000e-252, .off= 5.745344310051561161e-269 },
567 HP{.val=1.000000e-253, .off= -6.369110076296211879e-270 },
568 HP{.val=1.000000e-254, .off= 8.773957906638504842e-271 },
569 HP{.val=1.000000e-255, .off= -6.904595826956931908e-273 },
570 HP{.val=1.000000e-256, .off= 2.267170882721243669e-273 },
571 HP{.val=1.000000e-257, .off= 2.267170882721243669e-274 },
572 HP{.val=1.000000e-258, .off= 4.577819683828225398e-275 },
573 HP{.val=1.000000e-259, .off= -6.975424321706684210e-276 },
574 HP{.val=1.000000e-260, .off= 3.855741933482293648e-277 },
575 HP{.val=1.000000e-261, .off= 1.599248963651256552e-278 },
576 HP{.val=1.000000e-262, .off= -1.221367248637539543e-279 },
577 HP{.val=1.000000e-263, .off= -1.221367248637539494e-280 },
578 HP{.val=1.000000e-264, .off= -1.221367248637539647e-281 },
579 HP{.val=1.000000e-265, .off= 1.533140771175737943e-282 },
580 HP{.val=1.000000e-266, .off= 1.533140771175737895e-283 },
581 HP{.val=1.000000e-267, .off= 1.533140771175738074e-284 },
582 HP{.val=1.000000e-268, .off= 4.223090009274641634e-285 },
583 HP{.val=1.000000e-269, .off= 4.223090009274641634e-286 },
584 HP{.val=1.000000e-270, .off= -4.183001359784432924e-287 },
585 HP{.val=1.000000e-271, .off= 3.697709298708449474e-288 },
586 HP{.val=1.000000e-272, .off= 6.981338739747150474e-289 },
587 HP{.val=1.000000e-273, .off= -9.436808465446354751e-290 },
588 HP{.val=1.000000e-274, .off= 3.389869038611071740e-291 },
589 HP{.val=1.000000e-275, .off= 6.596538414625427829e-292 },
590 HP{.val=1.000000e-276, .off= -9.436808465446354618e-293 },
591 HP{.val=1.000000e-277, .off= 3.089243784609725523e-294 },
592 HP{.val=1.000000e-278, .off= 6.220756847123745836e-295 },
593 HP{.val=1.000000e-279, .off= -5.522417137303829470e-296 },
594 HP{.val=1.000000e-280, .off= 4.263561183052483059e-297 },
595 HP{.val=1.000000e-281, .off= -1.852675267170212272e-298 },
596 HP{.val=1.000000e-282, .off= -1.852675267170212378e-299 },
597 HP{.val=1.000000e-283, .off= 5.314789322934508480e-300 },
598 HP{.val=1.000000e-284, .off= -3.644541414696392675e-301 },
599 HP{.val=1.000000e-285, .off= -7.377595888709267777e-302 },
600 HP{.val=1.000000e-286, .off= -5.044436842451220838e-303 },
601 HP{.val=1.000000e-287, .off= -2.127988034628661760e-304 },
602 HP{.val=1.000000e-288, .off= -5.773549044406860911e-305 },
603 HP{.val=1.000000e-289, .off= -1.216597782184112068e-306 },
604 HP{.val=1.000000e-290, .off= -6.912786859962547924e-307 },
605 HP{.val=1.000000e-291, .off= 3.767567660872018813e-308 },
6 HP{ .val = 1.000000e+308, .off = -1.097906362944045488e+291 },
7 HP{ .val = 1.000000e+307, .off = 1.396894023974354241e+290 },
8 HP{ .val = 1.000000e+306, .off = -1.721606459673645508e+289 },
9 HP{ .val = 1.000000e+305, .off = 6.074644749446353973e+288 },
10 HP{ .val = 1.000000e+304, .off = 6.074644749446353567e+287 },
11 HP{ .val = 1.000000e+303, .off = -1.617650767864564452e+284 },
12 HP{ .val = 1.000000e+302, .off = -7.629703079084895055e+285 },
13 HP{ .val = 1.000000e+301, .off = -5.250476025520442286e+284 },
14 HP{ .val = 1.000000e+300, .off = -5.250476025520441956e+283 },
15 HP{ .val = 1.000000e+299, .off = -5.250476025520441750e+282 },
16 HP{ .val = 1.000000e+298, .off = 4.043379652465702264e+281 },
17 HP{ .val = 1.000000e+297, .off = -1.765280146275637946e+280 },
18 HP{ .val = 1.000000e+296, .off = 1.865132227937699609e+279 },
19 HP{ .val = 1.000000e+295, .off = 1.865132227937699609e+278 },
20 HP{ .val = 1.000000e+294, .off = -6.643646774124810287e+277 },
21 HP{ .val = 1.000000e+293, .off = 7.537651562646039934e+276 },
22 HP{ .val = 1.000000e+292, .off = -1.325659897835741608e+275 },
23 HP{ .val = 1.000000e+291, .off = 4.213909764965371606e+274 },
24 HP{ .val = 1.000000e+290, .off = -6.172783352786715670e+273 },
25 HP{ .val = 1.000000e+289, .off = -6.172783352786715670e+272 },
26 HP{ .val = 1.000000e+288, .off = -7.630473539575035471e+270 },
27 HP{ .val = 1.000000e+287, .off = -7.525217352494018700e+270 },
28 HP{ .val = 1.000000e+286, .off = -3.298861103408696612e+269 },
29 HP{ .val = 1.000000e+285, .off = 1.984084207947955778e+268 },
30 HP{ .val = 1.000000e+284, .off = -7.921438250845767591e+267 },
31 HP{ .val = 1.000000e+283, .off = 4.460464822646386735e+266 },
32 HP{ .val = 1.000000e+282, .off = -3.278224598286209647e+265 },
33 HP{ .val = 1.000000e+281, .off = -3.278224598286209737e+264 },
34 HP{ .val = 1.000000e+280, .off = -3.278224598286209961e+263 },
35 HP{ .val = 1.000000e+279, .off = -5.797329227496039232e+262 },
36 HP{ .val = 1.000000e+278, .off = 3.649313132040821498e+261 },
37 HP{ .val = 1.000000e+277, .off = -2.867878510995372374e+259 },
38 HP{ .val = 1.000000e+276, .off = -5.206914080024985409e+259 },
39 HP{ .val = 1.000000e+275, .off = 4.018322599210230404e+258 },
40 HP{ .val = 1.000000e+274, .off = 7.862171215558236495e+257 },
41 HP{ .val = 1.000000e+273, .off = 5.459765830340732821e+256 },
42 HP{ .val = 1.000000e+272, .off = -6.552261095746788047e+255 },
43 HP{ .val = 1.000000e+271, .off = 4.709014147460262298e+254 },
44 HP{ .val = 1.000000e+270, .off = -4.675381888545612729e+253 },
45 HP{ .val = 1.000000e+269, .off = -4.675381888545612892e+252 },
46 HP{ .val = 1.000000e+268, .off = 2.656177514583977380e+251 },
47 HP{ .val = 1.000000e+267, .off = 2.656177514583977190e+250 },
48 HP{ .val = 1.000000e+266, .off = -3.071603269111014892e+249 },
49 HP{ .val = 1.000000e+265, .off = -6.651466258920385440e+248 },
50 HP{ .val = 1.000000e+264, .off = -4.414051890289528972e+247 },
51 HP{ .val = 1.000000e+263, .off = -1.617283929500958387e+246 },
52 HP{ .val = 1.000000e+262, .off = -1.617283929500958241e+245 },
53 HP{ .val = 1.000000e+261, .off = 7.122615947963323868e+244 },
54 HP{ .val = 1.000000e+260, .off = -6.533477610574617382e+243 },
55 HP{ .val = 1.000000e+259, .off = 7.122615947963323982e+242 },
56 HP{ .val = 1.000000e+258, .off = -5.679971763165996225e+241 },
57 HP{ .val = 1.000000e+257, .off = -3.012765990014054219e+240 },
58 HP{ .val = 1.000000e+256, .off = -3.012765990014054219e+239 },
59 HP{ .val = 1.000000e+255, .off = 1.154743030535854616e+238 },
60 HP{ .val = 1.000000e+254, .off = 6.364129306223240767e+237 },
61 HP{ .val = 1.000000e+253, .off = 6.364129306223241129e+236 },
62 HP{ .val = 1.000000e+252, .off = -9.915202805299840595e+235 },
63 HP{ .val = 1.000000e+251, .off = -4.827911520448877980e+234 },
64 HP{ .val = 1.000000e+250, .off = 7.890316691678530146e+233 },
65 HP{ .val = 1.000000e+249, .off = 7.890316691678529484e+232 },
66 HP{ .val = 1.000000e+248, .off = -4.529828046727141859e+231 },
67 HP{ .val = 1.000000e+247, .off = 4.785280507077111924e+230 },
68 HP{ .val = 1.000000e+246, .off = -6.858605185178205305e+229 },
69 HP{ .val = 1.000000e+245, .off = -4.432795665958347728e+228 },
70 HP{ .val = 1.000000e+244, .off = -7.465057564983169531e+227 },
71 HP{ .val = 1.000000e+243, .off = -7.465057564983169741e+226 },
72 HP{ .val = 1.000000e+242, .off = -5.096102956370027445e+225 },
73 HP{ .val = 1.000000e+241, .off = -5.096102956370026952e+224 },
74 HP{ .val = 1.000000e+240, .off = -1.394611380411992474e+223 },
75 HP{ .val = 1.000000e+239, .off = 9.188208545617793960e+221 },
76 HP{ .val = 1.000000e+238, .off = -4.864759732872650359e+221 },
77 HP{ .val = 1.000000e+237, .off = 5.979453868566904629e+220 },
78 HP{ .val = 1.000000e+236, .off = -5.316601966265964857e+219 },
79 HP{ .val = 1.000000e+235, .off = -5.316601966265964701e+218 },
80 HP{ .val = 1.000000e+234, .off = -1.786584517880693123e+217 },
81 HP{ .val = 1.000000e+233, .off = 2.625937292600896716e+216 },
82 HP{ .val = 1.000000e+232, .off = -5.647541102052084079e+215 },
83 HP{ .val = 1.000000e+231, .off = -5.647541102052083888e+214 },
84 HP{ .val = 1.000000e+230, .off = -9.956644432600511943e+213 },
85 HP{ .val = 1.000000e+229, .off = 8.161138937705571862e+211 },
86 HP{ .val = 1.000000e+228, .off = 7.549087847752475275e+211 },
87 HP{ .val = 1.000000e+227, .off = -9.283347037202319948e+210 },
88 HP{ .val = 1.000000e+226, .off = 3.866992716668613820e+209 },
89 HP{ .val = 1.000000e+225, .off = 7.154577655136347262e+208 },
90 HP{ .val = 1.000000e+224, .off = 3.045096482051680688e+207 },
91 HP{ .val = 1.000000e+223, .off = -4.660180717482069567e+206 },
92 HP{ .val = 1.000000e+222, .off = -4.660180717482070101e+205 },
93 HP{ .val = 1.000000e+221, .off = -4.660180717482069544e+204 },
94 HP{ .val = 1.000000e+220, .off = 3.562757926310489022e+202 },
95 HP{ .val = 1.000000e+219, .off = 3.491561111451748149e+202 },
96 HP{ .val = 1.000000e+218, .off = -8.265758834125874135e+201 },
97 HP{ .val = 1.000000e+217, .off = 3.981449442517482365e+200 },
98 HP{ .val = 1.000000e+216, .off = -2.142154695804195936e+199 },
99 HP{ .val = 1.000000e+215, .off = 9.339603063548950188e+198 },
100 HP{ .val = 1.000000e+214, .off = 4.555537330485139746e+197 },
101 HP{ .val = 1.000000e+213, .off = 1.565496247320257804e+196 },
102 HP{ .val = 1.000000e+212, .off = 9.040598955232462036e+195 },
103 HP{ .val = 1.000000e+211, .off = 4.368659762787334780e+194 },
104 HP{ .val = 1.000000e+210, .off = 7.288621758065539072e+193 },
105 HP{ .val = 1.000000e+209, .off = -7.311188218325485628e+192 },
106 HP{ .val = 1.000000e+208, .off = 1.813693016918905189e+191 },
107 HP{ .val = 1.000000e+207, .off = -3.889357755108838992e+190 },
108 HP{ .val = 1.000000e+206, .off = -3.889357755108838992e+189 },
109 HP{ .val = 1.000000e+205, .off = -1.661603547285501360e+188 },
110 HP{ .val = 1.000000e+204, .off = 1.123089212493670643e+187 },
111 HP{ .val = 1.000000e+203, .off = 1.123089212493670643e+186 },
112 HP{ .val = 1.000000e+202, .off = 9.825254086803583029e+185 },
113 HP{ .val = 1.000000e+201, .off = -3.771878529305654999e+184 },
114 HP{ .val = 1.000000e+200, .off = 3.026687778748963675e+183 },
115 HP{ .val = 1.000000e+199, .off = -9.720624048853446693e+182 },
116 HP{ .val = 1.000000e+198, .off = -1.753554156601940139e+181 },
117 HP{ .val = 1.000000e+197, .off = 4.885670753607648963e+180 },
118 HP{ .val = 1.000000e+196, .off = 4.885670753607648963e+179 },
119 HP{ .val = 1.000000e+195, .off = 2.292223523057028076e+178 },
120 HP{ .val = 1.000000e+194, .off = 5.534032561245303825e+177 },
121 HP{ .val = 1.000000e+193, .off = -6.622751331960730683e+176 },
122 HP{ .val = 1.000000e+192, .off = -4.090088020876139692e+175 },
123 HP{ .val = 1.000000e+191, .off = -7.255917159731877552e+174 },
124 HP{ .val = 1.000000e+190, .off = -7.255917159731877992e+173 },
125 HP{ .val = 1.000000e+189, .off = -2.309309130269787104e+172 },
126 HP{ .val = 1.000000e+188, .off = -2.309309130269787019e+171 },
127 HP{ .val = 1.000000e+187, .off = 9.284303438781988230e+170 },
128 HP{ .val = 1.000000e+186, .off = 2.038295583124628364e+169 },
129 HP{ .val = 1.000000e+185, .off = 2.038295583124628532e+168 },
130 HP{ .val = 1.000000e+184, .off = -1.735666841696912925e+167 },
131 HP{ .val = 1.000000e+183, .off = 5.340512704843477241e+166 },
132 HP{ .val = 1.000000e+182, .off = -6.453119872723839321e+165 },
133 HP{ .val = 1.000000e+181, .off = 8.288920849235306587e+164 },
134 HP{ .val = 1.000000e+180, .off = -9.248546019891598293e+162 },
135 HP{ .val = 1.000000e+179, .off = 1.954450226518486016e+162 },
136 HP{ .val = 1.000000e+178, .off = -5.243811844750628197e+161 },
137 HP{ .val = 1.000000e+177, .off = -7.448980502074320639e+159 },
138 HP{ .val = 1.000000e+176, .off = -7.448980502074319858e+158 },
139 HP{ .val = 1.000000e+175, .off = 6.284654753766312753e+158 },
140 HP{ .val = 1.000000e+174, .off = -6.895756753684458388e+157 },
141 HP{ .val = 1.000000e+173, .off = -1.403918625579970616e+156 },
142 HP{ .val = 1.000000e+172, .off = -8.268716285710580522e+155 },
143 HP{ .val = 1.000000e+171, .off = 4.602779327034313170e+154 },
144 HP{ .val = 1.000000e+170, .off = -3.441905430931244940e+153 },
145 HP{ .val = 1.000000e+169, .off = 6.613950516525702884e+152 },
146 HP{ .val = 1.000000e+168, .off = 6.613950516525702652e+151 },
147 HP{ .val = 1.000000e+167, .off = -3.860899428741951187e+150 },
148 HP{ .val = 1.000000e+166, .off = 5.959272394946474605e+149 },
149 HP{ .val = 1.000000e+165, .off = 1.005101065481665103e+149 },
150 HP{ .val = 1.000000e+164, .off = -1.783349948587918355e+146 },
151 HP{ .val = 1.000000e+163, .off = 6.215006036188360099e+146 },
152 HP{ .val = 1.000000e+162, .off = 6.215006036188360099e+145 },
153 HP{ .val = 1.000000e+161, .off = -3.774589324822814903e+144 },
154 HP{ .val = 1.000000e+160, .off = -6.528407745068226929e+142 },
155 HP{ .val = 1.000000e+159, .off = 7.151530601283157561e+142 },
156 HP{ .val = 1.000000e+158, .off = 4.712664546348788765e+141 },
157 HP{ .val = 1.000000e+157, .off = 1.664081977680827856e+140 },
158 HP{ .val = 1.000000e+156, .off = 1.664081977680827750e+139 },
159 HP{ .val = 1.000000e+155, .off = -7.176231540910168265e+137 },
160 HP{ .val = 1.000000e+154, .off = -3.694754568805822650e+137 },
161 HP{ .val = 1.000000e+153, .off = 2.665969958768462622e+134 },
162 HP{ .val = 1.000000e+152, .off = -4.625108135904199522e+135 },
163 HP{ .val = 1.000000e+151, .off = -1.717753238721771919e+134 },
164 HP{ .val = 1.000000e+150, .off = 1.916440382756262433e+133 },
165 HP{ .val = 1.000000e+149, .off = -4.897672657515052040e+132 },
166 HP{ .val = 1.000000e+148, .off = -4.897672657515052198e+131 },
167 HP{ .val = 1.000000e+147, .off = 2.200361759434233991e+130 },
168 HP{ .val = 1.000000e+146, .off = 6.636633270027537273e+129 },
169 HP{ .val = 1.000000e+145, .off = 1.091293881785907977e+128 },
170 HP{ .val = 1.000000e+144, .off = -2.374543235865110597e+127 },
171 HP{ .val = 1.000000e+143, .off = -2.374543235865110537e+126 },
172 HP{ .val = 1.000000e+142, .off = -5.082228484029969099e+125 },
173 HP{ .val = 1.000000e+141, .off = -1.697621923823895943e+124 },
174 HP{ .val = 1.000000e+140, .off = -5.928380124081487212e+123 },
175 HP{ .val = 1.000000e+139, .off = -3.284156248920492522e+122 },
176 HP{ .val = 1.000000e+138, .off = -3.284156248920492706e+121 },
177 HP{ .val = 1.000000e+137, .off = -3.284156248920492476e+120 },
178 HP{ .val = 1.000000e+136, .off = -5.866406127007401066e+119 },
179 HP{ .val = 1.000000e+135, .off = 3.817030915818506056e+118 },
180 HP{ .val = 1.000000e+134, .off = 7.851796350329300951e+117 },
181 HP{ .val = 1.000000e+133, .off = -2.235117235947686077e+116 },
182 HP{ .val = 1.000000e+132, .off = 9.170432597638723691e+114 },
183 HP{ .val = 1.000000e+131, .off = 8.797444499042767883e+114 },
184 HP{ .val = 1.000000e+130, .off = -5.978307824605161274e+113 },
185 HP{ .val = 1.000000e+129, .off = 1.782556435814758516e+111 },
186 HP{ .val = 1.000000e+128, .off = -7.517448691651820362e+111 },
187 HP{ .val = 1.000000e+127, .off = 4.507089332150205498e+110 },
188 HP{ .val = 1.000000e+126, .off = 7.513223838100711695e+109 },
189 HP{ .val = 1.000000e+125, .off = 7.513223838100712113e+108 },
190 HP{ .val = 1.000000e+124, .off = 5.164681255326878494e+107 },
191 HP{ .val = 1.000000e+123, .off = 2.229003026859587122e+106 },
192 HP{ .val = 1.000000e+122, .off = -1.440594758724527399e+105 },
193 HP{ .val = 1.000000e+121, .off = -3.734093374714598783e+104 },
194 HP{ .val = 1.000000e+120, .off = 1.999653165260579757e+103 },
195 HP{ .val = 1.000000e+119, .off = 5.583244752745066693e+102 },
196 HP{ .val = 1.000000e+118, .off = 3.343500010567262234e+101 },
197 HP{ .val = 1.000000e+117, .off = -5.055542772599503556e+100 },
198 HP{ .val = 1.000000e+116, .off = -1.555941612946684331e+99 },
199 HP{ .val = 1.000000e+115, .off = -1.555941612946684331e+98 },
200 HP{ .val = 1.000000e+114, .off = -1.555941612946684293e+97 },
201 HP{ .val = 1.000000e+113, .off = -1.555941612946684246e+96 },
202 HP{ .val = 1.000000e+112, .off = 6.988006530736955847e+95 },
203 HP{ .val = 1.000000e+111, .off = 4.318022735835818244e+94 },
204 HP{ .val = 1.000000e+110, .off = -2.356936751417025578e+93 },
205 HP{ .val = 1.000000e+109, .off = 1.814912928116001926e+92 },
206 HP{ .val = 1.000000e+108, .off = -3.399899171300282744e+91 },
207 HP{ .val = 1.000000e+107, .off = 3.118615952970072913e+90 },
208 HP{ .val = 1.000000e+106, .off = -9.103599905036843605e+89 },
209 HP{ .val = 1.000000e+105, .off = 6.174169917471802325e+88 },
210 HP{ .val = 1.000000e+104, .off = -1.915675085734668657e+86 },
211 HP{ .val = 1.000000e+103, .off = -1.915675085734668864e+85 },
212 HP{ .val = 1.000000e+102, .off = 2.295048673475466221e+85 },
213 HP{ .val = 1.000000e+101, .off = 2.295048673475466135e+84 },
214 HP{ .val = 1.000000e+100, .off = -1.590289110975991792e+83 },
215 HP{ .val = 1.000000e+99, .off = 3.266383119588331155e+82 },
216 HP{ .val = 1.000000e+98, .off = 2.309629754856292029e+80 },
217 HP{ .val = 1.000000e+97, .off = -7.357587384771124533e+80 },
218 HP{ .val = 1.000000e+96, .off = -4.986165397190889509e+79 },
219 HP{ .val = 1.000000e+95, .off = -2.021887912715594741e+78 },
220 HP{ .val = 1.000000e+94, .off = -2.021887912715594638e+77 },
221 HP{ .val = 1.000000e+93, .off = -4.337729697461918675e+76 },
222 HP{ .val = 1.000000e+92, .off = -4.337729697461918997e+75 },
223 HP{ .val = 1.000000e+91, .off = -7.956232486128049702e+74 },
224 HP{ .val = 1.000000e+90, .off = 3.351588728453609882e+73 },
225 HP{ .val = 1.000000e+89, .off = 5.246334248081951113e+71 },
226 HP{ .val = 1.000000e+88, .off = 4.058327554364963672e+71 },
227 HP{ .val = 1.000000e+87, .off = 4.058327554364963918e+70 },
228 HP{ .val = 1.000000e+86, .off = -1.463069523067487266e+69 },
229 HP{ .val = 1.000000e+85, .off = -1.463069523067487314e+68 },
230 HP{ .val = 1.000000e+84, .off = -5.776660989811589441e+67 },
231 HP{ .val = 1.000000e+83, .off = -3.080666323096525761e+66 },
232 HP{ .val = 1.000000e+82, .off = 3.659320343691134468e+65 },
233 HP{ .val = 1.000000e+81, .off = 7.871812010433421235e+64 },
234 HP{ .val = 1.000000e+80, .off = -2.660986470836727449e+61 },
235 HP{ .val = 1.000000e+79, .off = 3.264399249934044627e+62 },
236 HP{ .val = 1.000000e+78, .off = -8.493621433689703070e+60 },
237 HP{ .val = 1.000000e+77, .off = 1.721738727445414063e+60 },
238 HP{ .val = 1.000000e+76, .off = -4.706013449590547218e+59 },
239 HP{ .val = 1.000000e+75, .off = 7.346021882351880518e+58 },
240 HP{ .val = 1.000000e+74, .off = 4.835181188197207515e+57 },
241 HP{ .val = 1.000000e+73, .off = 1.696630320503867482e+56 },
242 HP{ .val = 1.000000e+72, .off = 5.619818905120542959e+55 },
243 HP{ .val = 1.000000e+71, .off = -4.188152556421145598e+54 },
244 HP{ .val = 1.000000e+70, .off = -7.253143638152923145e+53 },
245 HP{ .val = 1.000000e+69, .off = -7.253143638152923145e+52 },
246 HP{ .val = 1.000000e+68, .off = 4.719477774861832896e+51 },
247 HP{ .val = 1.000000e+67, .off = 1.726322421608144052e+50 },
248 HP{ .val = 1.000000e+66, .off = 5.467766613175255107e+49 },
249 HP{ .val = 1.000000e+65, .off = 7.909613737163661911e+47 },
250 HP{ .val = 1.000000e+64, .off = -2.132041900945439564e+47 },
251 HP{ .val = 1.000000e+63, .off = -5.785795994272697265e+46 },
252 HP{ .val = 1.000000e+62, .off = -3.502199685943161329e+45 },
253 HP{ .val = 1.000000e+61, .off = 5.061286470292598274e+44 },
254 HP{ .val = 1.000000e+60, .off = 5.061286470292598472e+43 },
255 HP{ .val = 1.000000e+59, .off = 2.831211950439536034e+42 },
256 HP{ .val = 1.000000e+58, .off = 5.618805100255863927e+41 },
257 HP{ .val = 1.000000e+57, .off = -4.834669211555366251e+40 },
258 HP{ .val = 1.000000e+56, .off = -9.190283508143378583e+39 },
259 HP{ .val = 1.000000e+55, .off = -1.023506702040855158e+38 },
260 HP{ .val = 1.000000e+54, .off = -7.829154040459624616e+37 },
261 HP{ .val = 1.000000e+53, .off = 6.779051325638372659e+35 },
262 HP{ .val = 1.000000e+52, .off = 6.779051325638372290e+34 },
263 HP{ .val = 1.000000e+51, .off = 6.779051325638371598e+33 },
264 HP{ .val = 1.000000e+50, .off = -7.629769841091887392e+33 },
265 HP{ .val = 1.000000e+49, .off = 5.350972305245182400e+32 },
266 HP{ .val = 1.000000e+48, .off = -4.384584304507619764e+31 },
267 HP{ .val = 1.000000e+47, .off = -4.384584304507619876e+30 },
268 HP{ .val = 1.000000e+46, .off = 6.860180964052978705e+28 },
269 HP{ .val = 1.000000e+45, .off = 7.024271097546444878e+28 },
270 HP{ .val = 1.000000e+44, .off = -8.821361405306422641e+27 },
271 HP{ .val = 1.000000e+43, .off = -1.393721169594140991e+26 },
272 HP{ .val = 1.000000e+42, .off = -4.488571267807591679e+25 },
273 HP{ .val = 1.000000e+41, .off = -6.200086450407783195e+23 },
274 HP{ .val = 1.000000e+40, .off = -3.037860284270036669e+23 },
275 HP{ .val = 1.000000e+39, .off = 6.029083362839682141e+22 },
276 HP{ .val = 1.000000e+38, .off = 2.251190176543965970e+21 },
277 HP{ .val = 1.000000e+37, .off = 4.612373417978788577e+20 },
278 HP{ .val = 1.000000e+36, .off = -4.242063737401796198e+19 },
279 HP{ .val = 1.000000e+35, .off = 3.136633892082024448e+18 },
280 HP{ .val = 1.000000e+34, .off = 5.442476901295718400e+17 },
281 HP{ .val = 1.000000e+33, .off = 5.442476901295718400e+16 },
282 HP{ .val = 1.000000e+32, .off = -5.366162204393472000e+15 },
283 HP{ .val = 1.000000e+31, .off = 3.641037050347520000e+14 },
284 HP{ .val = 1.000000e+30, .off = -1.988462483865600000e+13 },
285 HP{ .val = 1.000000e+29, .off = 8.566849142784000000e+12 },
286 HP{ .val = 1.000000e+28, .off = 4.168802631680000000e+11 },
287 HP{ .val = 1.000000e+27, .off = -1.328755507200000000e+10 },
288 HP{ .val = 1.000000e+26, .off = -4.764729344000000000e+09 },
289 HP{ .val = 1.000000e+25, .off = -9.059696640000000000e+08 },
290 HP{ .val = 1.000000e+24, .off = 1.677721600000000000e+07 },
291 HP{ .val = 1.000000e+23, .off = 8.388608000000000000e+06 },
292 HP{ .val = 1.000000e+22, .off = 0.000000000000000000e+00 },
293 HP{ .val = 1.000000e+21, .off = 0.000000000000000000e+00 },
294 HP{ .val = 1.000000e+20, .off = 0.000000000000000000e+00 },
295 HP{ .val = 1.000000e+19, .off = 0.000000000000000000e+00 },
296 HP{ .val = 1.000000e+18, .off = 0.000000000000000000e+00 },
297 HP{ .val = 1.000000e+17, .off = 0.000000000000000000e+00 },
298 HP{ .val = 1.000000e+16, .off = 0.000000000000000000e+00 },
299 HP{ .val = 1.000000e+15, .off = 0.000000000000000000e+00 },
300 HP{ .val = 1.000000e+14, .off = 0.000000000000000000e+00 },
301 HP{ .val = 1.000000e+13, .off = 0.000000000000000000e+00 },
302 HP{ .val = 1.000000e+12, .off = 0.000000000000000000e+00 },
303 HP{ .val = 1.000000e+11, .off = 0.000000000000000000e+00 },
304 HP{ .val = 1.000000e+10, .off = 0.000000000000000000e+00 },
305 HP{ .val = 1.000000e+09, .off = 0.000000000000000000e+00 },
306 HP{ .val = 1.000000e+08, .off = 0.000000000000000000e+00 },
307 HP{ .val = 1.000000e+07, .off = 0.000000000000000000e+00 },
308 HP{ .val = 1.000000e+06, .off = 0.000000000000000000e+00 },
309 HP{ .val = 1.000000e+05, .off = 0.000000000000000000e+00 },
310 HP{ .val = 1.000000e+04, .off = 0.000000000000000000e+00 },
311 HP{ .val = 1.000000e+03, .off = 0.000000000000000000e+00 },
312 HP{ .val = 1.000000e+02, .off = 0.000000000000000000e+00 },
313 HP{ .val = 1.000000e+01, .off = 0.000000000000000000e+00 },
314 HP{ .val = 1.000000e+00, .off = 0.000000000000000000e+00 },
315 HP{ .val = 1.000000e-01, .off = -5.551115123125783010e-18 },
316 HP{ .val = 1.000000e-02, .off = -2.081668171172168436e-19 },
317 HP{ .val = 1.000000e-03, .off = -2.081668171172168557e-20 },
318 HP{ .val = 1.000000e-04, .off = -4.792173602385929943e-21 },
319 HP{ .val = 1.000000e-05, .off = -8.180305391403130547e-22 },
320 HP{ .val = 1.000000e-06, .off = 4.525188817411374069e-23 },
321 HP{ .val = 1.000000e-07, .off = 4.525188817411373922e-24 },
322 HP{ .val = 1.000000e-08, .off = -2.092256083012847109e-25 },
323 HP{ .val = 1.000000e-09, .off = -6.228159145777985254e-26 },
324 HP{ .val = 1.000000e-10, .off = -3.643219731549774344e-27 },
325 HP{ .val = 1.000000e-11, .off = 6.050303071806019080e-28 },
326 HP{ .val = 1.000000e-12, .off = 2.011335237074438524e-29 },
327 HP{ .val = 1.000000e-13, .off = -3.037374556340037101e-30 },
328 HP{ .val = 1.000000e-14, .off = 1.180690645440101289e-32 },
329 HP{ .val = 1.000000e-15, .off = -7.770539987666107583e-32 },
330 HP{ .val = 1.000000e-16, .off = 2.090221327596539779e-33 },
331 HP{ .val = 1.000000e-17, .off = -7.154242405462192144e-34 },
332 HP{ .val = 1.000000e-18, .off = -7.154242405462192572e-35 },
333 HP{ .val = 1.000000e-19, .off = 2.475407316473986894e-36 },
334 HP{ .val = 1.000000e-20, .off = 5.484672854579042914e-37 },
335 HP{ .val = 1.000000e-21, .off = 9.246254777210362522e-38 },
336 HP{ .val = 1.000000e-22, .off = -4.859677432657087182e-39 },
337 HP{ .val = 1.000000e-23, .off = 3.956530198510069291e-40 },
338 HP{ .val = 1.000000e-24, .off = 7.629950044829717753e-41 },
339 HP{ .val = 1.000000e-25, .off = -3.849486974919183692e-42 },
340 HP{ .val = 1.000000e-26, .off = -3.849486974919184170e-43 },
341 HP{ .val = 1.000000e-27, .off = -3.849486974919184070e-44 },
342 HP{ .val = 1.000000e-28, .off = 2.876745653839937870e-45 },
343 HP{ .val = 1.000000e-29, .off = 5.679342582489572168e-46 },
344 HP{ .val = 1.000000e-30, .off = -8.333642060758598930e-47 },
345 HP{ .val = 1.000000e-31, .off = -8.333642060758597958e-48 },
346 HP{ .val = 1.000000e-32, .off = -5.596730997624190224e-49 },
347 HP{ .val = 1.000000e-33, .off = -5.596730997624190604e-50 },
348 HP{ .val = 1.000000e-34, .off = 7.232539610818348498e-51 },
349 HP{ .val = 1.000000e-35, .off = -7.857545194582380514e-53 },
350 HP{ .val = 1.000000e-36, .off = 5.896157255772251528e-53 },
351 HP{ .val = 1.000000e-37, .off = -6.632427322784915796e-54 },
352 HP{ .val = 1.000000e-38, .off = 3.808059826012723592e-55 },
353 HP{ .val = 1.000000e-39, .off = 7.070712060011985131e-56 },
354 HP{ .val = 1.000000e-40, .off = 7.070712060011985584e-57 },
355 HP{ .val = 1.000000e-41, .off = -5.761291134237854167e-59 },
356 HP{ .val = 1.000000e-42, .off = -3.762312935688689794e-59 },
357 HP{ .val = 1.000000e-43, .off = -7.745042713519821150e-60 },
358 HP{ .val = 1.000000e-44, .off = 4.700987842202462817e-61 },
359 HP{ .val = 1.000000e-45, .off = 1.589480203271891964e-62 },
360 HP{ .val = 1.000000e-46, .off = -2.299904345391321765e-63 },
361 HP{ .val = 1.000000e-47, .off = 2.561826340437695261e-64 },
362 HP{ .val = 1.000000e-48, .off = 2.561826340437695345e-65 },
363 HP{ .val = 1.000000e-49, .off = 6.360053438741614633e-66 },
364 HP{ .val = 1.000000e-50, .off = -7.616223705782342295e-68 },
365 HP{ .val = 1.000000e-51, .off = -7.616223705782343324e-69 },
366 HP{ .val = 1.000000e-52, .off = -7.616223705782342295e-70 },
367 HP{ .val = 1.000000e-53, .off = -3.079876214757872338e-70 },
368 HP{ .val = 1.000000e-54, .off = -3.079876214757872821e-71 },
369 HP{ .val = 1.000000e-55, .off = 5.423954167728123147e-73 },
370 HP{ .val = 1.000000e-56, .off = -3.985444122640543680e-73 },
371 HP{ .val = 1.000000e-57, .off = 4.504255013759498850e-74 },
372 HP{ .val = 1.000000e-58, .off = -2.570494266573869991e-75 },
373 HP{ .val = 1.000000e-59, .off = -2.570494266573869930e-76 },
374 HP{ .val = 1.000000e-60, .off = 2.956653608686574324e-77 },
375 HP{ .val = 1.000000e-61, .off = -3.952281235388981376e-78 },
376 HP{ .val = 1.000000e-62, .off = -3.952281235388981376e-79 },
377 HP{ .val = 1.000000e-63, .off = -6.651083908855995172e-80 },
378 HP{ .val = 1.000000e-64, .off = 3.469426116645307030e-81 },
379 HP{ .val = 1.000000e-65, .off = 7.686305293937516319e-82 },
380 HP{ .val = 1.000000e-66, .off = 2.415206322322254927e-83 },
381 HP{ .val = 1.000000e-67, .off = 5.709643179581793251e-84 },
382 HP{ .val = 1.000000e-68, .off = -6.644495035141475923e-85 },
383 HP{ .val = 1.000000e-69, .off = 3.650620143794581913e-86 },
384 HP{ .val = 1.000000e-70, .off = 4.333966503770636492e-88 },
385 HP{ .val = 1.000000e-71, .off = 8.476455383920859113e-88 },
386 HP{ .val = 1.000000e-72, .off = 3.449543675455986564e-89 },
387 HP{ .val = 1.000000e-73, .off = 3.077238576654418974e-91 },
388 HP{ .val = 1.000000e-74, .off = 4.234998629903623140e-91 },
389 HP{ .val = 1.000000e-75, .off = 4.234998629903623412e-92 },
390 HP{ .val = 1.000000e-76, .off = 7.303182045714702338e-93 },
391 HP{ .val = 1.000000e-77, .off = 7.303182045714701699e-94 },
392 HP{ .val = 1.000000e-78, .off = 1.121271649074855759e-96 },
393 HP{ .val = 1.000000e-79, .off = 1.121271649074855863e-97 },
394 HP{ .val = 1.000000e-80, .off = 3.857468248661243988e-97 },
395 HP{ .val = 1.000000e-81, .off = 3.857468248661244248e-98 },
396 HP{ .val = 1.000000e-82, .off = 3.857468248661244410e-99 },
397 HP{ .val = 1.000000e-83, .off = -3.457651055545315679e-100 },
398 HP{ .val = 1.000000e-84, .off = -3.457651055545315933e-101 },
399 HP{ .val = 1.000000e-85, .off = 2.257285900866059216e-102 },
400 HP{ .val = 1.000000e-86, .off = -8.458220892405268345e-103 },
401 HP{ .val = 1.000000e-87, .off = -1.761029146610688867e-104 },
402 HP{ .val = 1.000000e-88, .off = 6.610460535632536565e-105 },
403 HP{ .val = 1.000000e-89, .off = -3.853901567171494935e-106 },
404 HP{ .val = 1.000000e-90, .off = 5.062493089968513723e-108 },
405 HP{ .val = 1.000000e-91, .off = -2.218844988608365240e-108 },
406 HP{ .val = 1.000000e-92, .off = 1.187522883398155383e-109 },
407 HP{ .val = 1.000000e-93, .off = 9.703442563414457296e-110 },
408 HP{ .val = 1.000000e-94, .off = 4.380992763404268896e-111 },
409 HP{ .val = 1.000000e-95, .off = 1.054461638397900823e-112 },
410 HP{ .val = 1.000000e-96, .off = 9.370789450913819736e-113 },
411 HP{ .val = 1.000000e-97, .off = -3.623472756142303998e-114 },
412 HP{ .val = 1.000000e-98, .off = 6.122223899149788839e-115 },
413 HP{ .val = 1.000000e-99, .off = -1.999189980260288281e-116 },
414 HP{ .val = 1.000000e-100, .off = -1.999189980260288281e-117 },
415 HP{ .val = 1.000000e-101, .off = -5.171617276904849634e-118 },
416 HP{ .val = 1.000000e-102, .off = 6.724985085512256320e-119 },
417 HP{ .val = 1.000000e-103, .off = 4.246526260008692213e-120 },
418 HP{ .val = 1.000000e-104, .off = 7.344599791888147003e-121 },
419 HP{ .val = 1.000000e-105, .off = 3.472007877038828407e-122 },
420 HP{ .val = 1.000000e-106, .off = 5.892377823819652194e-123 },
421 HP{ .val = 1.000000e-107, .off = -1.585470431324073925e-125 },
422 HP{ .val = 1.000000e-108, .off = -3.940375084977444795e-125 },
423 HP{ .val = 1.000000e-109, .off = 7.869099673288519908e-127 },
424 HP{ .val = 1.000000e-110, .off = -5.122196348054018581e-127 },
425 HP{ .val = 1.000000e-111, .off = -8.815387795168313713e-128 },
426 HP{ .val = 1.000000e-112, .off = 5.034080131510290214e-129 },
427 HP{ .val = 1.000000e-113, .off = 2.148774313452247863e-130 },
428 HP{ .val = 1.000000e-114, .off = -5.064490231692858416e-131 },
429 HP{ .val = 1.000000e-115, .off = -5.064490231692858166e-132 },
430 HP{ .val = 1.000000e-116, .off = 5.708726942017560559e-134 },
431 HP{ .val = 1.000000e-117, .off = -2.951229134482377772e-134 },
432 HP{ .val = 1.000000e-118, .off = 1.451398151372789513e-135 },
433 HP{ .val = 1.000000e-119, .off = -1.300243902286690040e-136 },
434 HP{ .val = 1.000000e-120, .off = 2.139308664787659449e-137 },
435 HP{ .val = 1.000000e-121, .off = 2.139308664787659329e-138 },
436 HP{ .val = 1.000000e-122, .off = -5.922142664292847471e-139 },
437 HP{ .val = 1.000000e-123, .off = -5.922142664292846912e-140 },
438 HP{ .val = 1.000000e-124, .off = 6.673875037395443799e-141 },
439 HP{ .val = 1.000000e-125, .off = -1.198636026159737932e-142 },
440 HP{ .val = 1.000000e-126, .off = 5.361789860136246995e-143 },
441 HP{ .val = 1.000000e-127, .off = -2.838742497733733936e-144 },
442 HP{ .val = 1.000000e-128, .off = -5.401408859568103261e-145 },
443 HP{ .val = 1.000000e-129, .off = 7.411922949603743011e-146 },
444 HP{ .val = 1.000000e-130, .off = -8.604741811861064385e-147 },
445 HP{ .val = 1.000000e-131, .off = 1.405673664054439890e-148 },
446 HP{ .val = 1.000000e-132, .off = 1.405673664054439933e-149 },
447 HP{ .val = 1.000000e-133, .off = -6.414963426504548053e-150 },
448 HP{ .val = 1.000000e-134, .off = -3.971014335704864578e-151 },
449 HP{ .val = 1.000000e-135, .off = -3.971014335704864748e-152 },
450 HP{ .val = 1.000000e-136, .off = -1.523438813303585576e-154 },
451 HP{ .val = 1.000000e-137, .off = 2.234325152653707766e-154 },
452 HP{ .val = 1.000000e-138, .off = -6.715683724786540160e-155 },
453 HP{ .val = 1.000000e-139, .off = -2.986513359186437306e-156 },
454 HP{ .val = 1.000000e-140, .off = 1.674949597813692102e-157 },
455 HP{ .val = 1.000000e-141, .off = -4.151879098436469092e-158 },
456 HP{ .val = 1.000000e-142, .off = -4.151879098436469295e-159 },
457 HP{ .val = 1.000000e-143, .off = 4.952540739454407825e-160 },
458 HP{ .val = 1.000000e-144, .off = 4.952540739454407667e-161 },
459 HP{ .val = 1.000000e-145, .off = 8.508954738630531443e-162 },
460 HP{ .val = 1.000000e-146, .off = -2.604839008794855481e-163 },
461 HP{ .val = 1.000000e-147, .off = 2.952057864917838382e-164 },
462 HP{ .val = 1.000000e-148, .off = 6.425118410988271757e-165 },
463 HP{ .val = 1.000000e-149, .off = 2.083792728400229858e-166 },
464 HP{ .val = 1.000000e-150, .off = -6.295358232172964237e-168 },
465 HP{ .val = 1.000000e-151, .off = 6.153785555826519421e-168 },
466 HP{ .val = 1.000000e-152, .off = -6.564942029880634994e-169 },
467 HP{ .val = 1.000000e-153, .off = -3.915207116191644540e-170 },
468 HP{ .val = 1.000000e-154, .off = 2.709130168030831503e-171 },
469 HP{ .val = 1.000000e-155, .off = -1.431080634608215966e-172 },
470 HP{ .val = 1.000000e-156, .off = -4.018712386257620994e-173 },
471 HP{ .val = 1.000000e-157, .off = 5.684906682427646782e-174 },
472 HP{ .val = 1.000000e-158, .off = -6.444617153428937489e-175 },
473 HP{ .val = 1.000000e-159, .off = 1.136335243981427681e-176 },
474 HP{ .val = 1.000000e-160, .off = 1.136335243981427725e-177 },
475 HP{ .val = 1.000000e-161, .off = -2.812077463003137395e-178 },
476 HP{ .val = 1.000000e-162, .off = 4.591196362592922204e-179 },
477 HP{ .val = 1.000000e-163, .off = 7.675893789924613703e-180 },
478 HP{ .val = 1.000000e-164, .off = 3.820022005759999543e-181 },
479 HP{ .val = 1.000000e-165, .off = -9.998177244457686588e-183 },
480 HP{ .val = 1.000000e-166, .off = -4.012217555824373639e-183 },
481 HP{ .val = 1.000000e-167, .off = -2.467177666011174334e-185 },
482 HP{ .val = 1.000000e-168, .off = -4.953592503130188139e-185 },
483 HP{ .val = 1.000000e-169, .off = -2.011795792799518887e-186 },
484 HP{ .val = 1.000000e-170, .off = 1.665450095113817423e-187 },
485 HP{ .val = 1.000000e-171, .off = 1.665450095113817487e-188 },
486 HP{ .val = 1.000000e-172, .off = -4.080246604750770577e-189 },
487 HP{ .val = 1.000000e-173, .off = -4.080246604750770677e-190 },
488 HP{ .val = 1.000000e-174, .off = 4.085789420184387951e-192 },
489 HP{ .val = 1.000000e-175, .off = 4.085789420184388146e-193 },
490 HP{ .val = 1.000000e-176, .off = 4.085789420184388146e-194 },
491 HP{ .val = 1.000000e-177, .off = 4.792197640035244894e-194 },
492 HP{ .val = 1.000000e-178, .off = 4.792197640035244742e-195 },
493 HP{ .val = 1.000000e-179, .off = -2.057206575616014662e-196 },
494 HP{ .val = 1.000000e-180, .off = -2.057206575616014662e-197 },
495 HP{ .val = 1.000000e-181, .off = -4.732755097354788053e-198 },
496 HP{ .val = 1.000000e-182, .off = -4.732755097354787867e-199 },
497 HP{ .val = 1.000000e-183, .off = -5.522105321379546765e-201 },
498 HP{ .val = 1.000000e-184, .off = -5.777891238658996019e-201 },
499 HP{ .val = 1.000000e-185, .off = 7.542096444923057046e-203 },
500 HP{ .val = 1.000000e-186, .off = 8.919335748431433483e-203 },
501 HP{ .val = 1.000000e-187, .off = -1.287071881492476028e-204 },
502 HP{ .val = 1.000000e-188, .off = 5.091932887209967018e-205 },
503 HP{ .val = 1.000000e-189, .off = -6.868701054107114024e-206 },
504 HP{ .val = 1.000000e-190, .off = -1.885103578558330118e-207 },
505 HP{ .val = 1.000000e-191, .off = -1.885103578558330205e-208 },
506 HP{ .val = 1.000000e-192, .off = -9.671974634103305058e-209 },
507 HP{ .val = 1.000000e-193, .off = -4.805180224387695640e-210 },
508 HP{ .val = 1.000000e-194, .off = -1.763433718315439838e-211 },
509 HP{ .val = 1.000000e-195, .off = -9.367799983496079132e-212 },
510 HP{ .val = 1.000000e-196, .off = -4.615071067758179837e-213 },
511 HP{ .val = 1.000000e-197, .off = 1.325840076914194777e-214 },
512 HP{ .val = 1.000000e-198, .off = 8.751979007754662425e-215 },
513 HP{ .val = 1.000000e-199, .off = 1.789973760091724198e-216 },
514 HP{ .val = 1.000000e-200, .off = 1.789973760091724077e-217 },
515 HP{ .val = 1.000000e-201, .off = 5.416018159916171171e-218 },
516 HP{ .val = 1.000000e-202, .off = -3.649092839644947067e-219 },
517 HP{ .val = 1.000000e-203, .off = -3.649092839644947067e-220 },
518 HP{ .val = 1.000000e-204, .off = -1.080338554413850956e-222 },
519 HP{ .val = 1.000000e-205, .off = -1.080338554413850841e-223 },
520 HP{ .val = 1.000000e-206, .off = -2.874486186850417807e-223 },
521 HP{ .val = 1.000000e-207, .off = 7.499710055933455072e-224 },
522 HP{ .val = 1.000000e-208, .off = -9.790617015372999087e-225 },
523 HP{ .val = 1.000000e-209, .off = -4.387389805589732612e-226 },
524 HP{ .val = 1.000000e-210, .off = -4.387389805589732612e-227 },
525 HP{ .val = 1.000000e-211, .off = -8.608661063232909897e-228 },
526 HP{ .val = 1.000000e-212, .off = 4.582811616902018972e-229 },
527 HP{ .val = 1.000000e-213, .off = 4.582811616902019155e-230 },
528 HP{ .val = 1.000000e-214, .off = 8.705146829444184930e-231 },
529 HP{ .val = 1.000000e-215, .off = -4.177150709750081830e-232 },
530 HP{ .val = 1.000000e-216, .off = -4.177150709750082366e-233 },
531 HP{ .val = 1.000000e-217, .off = -8.202868690748290237e-234 },
532 HP{ .val = 1.000000e-218, .off = -3.170721214500530119e-235 },
533 HP{ .val = 1.000000e-219, .off = -3.170721214500529857e-236 },
534 HP{ .val = 1.000000e-220, .off = 7.606440013180328441e-238 },
535 HP{ .val = 1.000000e-221, .off = -1.696459258568569049e-238 },
536 HP{ .val = 1.000000e-222, .off = -4.767838333426821244e-239 },
537 HP{ .val = 1.000000e-223, .off = 2.910609353718809138e-240 },
538 HP{ .val = 1.000000e-224, .off = -1.888420450747209784e-241 },
539 HP{ .val = 1.000000e-225, .off = 4.110366804835314035e-242 },
540 HP{ .val = 1.000000e-226, .off = 7.859608839574391006e-243 },
541 HP{ .val = 1.000000e-227, .off = 5.516332567862468419e-244 },
542 HP{ .val = 1.000000e-228, .off = -3.270953451057244613e-245 },
543 HP{ .val = 1.000000e-229, .off = -6.932322625607124670e-246 },
544 HP{ .val = 1.000000e-230, .off = -4.643966891513449762e-247 },
545 HP{ .val = 1.000000e-231, .off = 1.076922443720738305e-248 },
546 HP{ .val = 1.000000e-232, .off = -2.498633390800628939e-249 },
547 HP{ .val = 1.000000e-233, .off = 4.205533798926934891e-250 },
548 HP{ .val = 1.000000e-234, .off = 4.205533798926934891e-251 },
549 HP{ .val = 1.000000e-235, .off = 4.205533798926934697e-252 },
550 HP{ .val = 1.000000e-236, .off = -4.523850562697497656e-253 },
551 HP{ .val = 1.000000e-237, .off = 9.320146633177728298e-255 },
552 HP{ .val = 1.000000e-238, .off = 9.320146633177728062e-256 },
553 HP{ .val = 1.000000e-239, .off = -7.592774752331086440e-256 },
554 HP{ .val = 1.000000e-240, .off = 3.063212017229987840e-257 },
555 HP{ .val = 1.000000e-241, .off = 3.063212017229987562e-258 },
556 HP{ .val = 1.000000e-242, .off = 3.063212017229987562e-259 },
557 HP{ .val = 1.000000e-243, .off = 4.616527473176159842e-261 },
558 HP{ .val = 1.000000e-244, .off = 6.965550922098544975e-261 },
559 HP{ .val = 1.000000e-245, .off = 6.965550922098544749e-262 },
560 HP{ .val = 1.000000e-246, .off = 4.424965697574744679e-263 },
561 HP{ .val = 1.000000e-247, .off = -1.926497363734756420e-264 },
562 HP{ .val = 1.000000e-248, .off = 2.043167049583681740e-265 },
563 HP{ .val = 1.000000e-249, .off = -5.399953725388390154e-266 },
564 HP{ .val = 1.000000e-250, .off = -5.399953725388389982e-267 },
565 HP{ .val = 1.000000e-251, .off = -1.523328321757102663e-268 },
566 HP{ .val = 1.000000e-252, .off = 5.745344310051561161e-269 },
567 HP{ .val = 1.000000e-253, .off = -6.369110076296211879e-270 },
568 HP{ .val = 1.000000e-254, .off = 8.773957906638504842e-271 },
569 HP{ .val = 1.000000e-255, .off = -6.904595826956931908e-273 },
570 HP{ .val = 1.000000e-256, .off = 2.267170882721243669e-273 },
571 HP{ .val = 1.000000e-257, .off = 2.267170882721243669e-274 },
572 HP{ .val = 1.000000e-258, .off = 4.577819683828225398e-275 },
573 HP{ .val = 1.000000e-259, .off = -6.975424321706684210e-276 },
574 HP{ .val = 1.000000e-260, .off = 3.855741933482293648e-277 },
575 HP{ .val = 1.000000e-261, .off = 1.599248963651256552e-278 },
576 HP{ .val = 1.000000e-262, .off = -1.221367248637539543e-279 },
577 HP{ .val = 1.000000e-263, .off = -1.221367248637539494e-280 },
578 HP{ .val = 1.000000e-264, .off = -1.221367248637539647e-281 },
579 HP{ .val = 1.000000e-265, .off = 1.533140771175737943e-282 },
580 HP{ .val = 1.000000e-266, .off = 1.533140771175737895e-283 },
581 HP{ .val = 1.000000e-267, .off = 1.533140771175738074e-284 },
582 HP{ .val = 1.000000e-268, .off = 4.223090009274641634e-285 },
583 HP{ .val = 1.000000e-269, .off = 4.223090009274641634e-286 },
584 HP{ .val = 1.000000e-270, .off = -4.183001359784432924e-287 },
585 HP{ .val = 1.000000e-271, .off = 3.697709298708449474e-288 },
586 HP{ .val = 1.000000e-272, .off = 6.981338739747150474e-289 },
587 HP{ .val = 1.000000e-273, .off = -9.436808465446354751e-290 },
588 HP{ .val = 1.000000e-274, .off = 3.389869038611071740e-291 },
589 HP{ .val = 1.000000e-275, .off = 6.596538414625427829e-292 },
590 HP{ .val = 1.000000e-276, .off = -9.436808465446354618e-293 },
591 HP{ .val = 1.000000e-277, .off = 3.089243784609725523e-294 },
592 HP{ .val = 1.000000e-278, .off = 6.220756847123745836e-295 },
593 HP{ .val = 1.000000e-279, .off = -5.522417137303829470e-296 },
594 HP{ .val = 1.000000e-280, .off = 4.263561183052483059e-297 },
595 HP{ .val = 1.000000e-281, .off = -1.852675267170212272e-298 },
596 HP{ .val = 1.000000e-282, .off = -1.852675267170212378e-299 },
597 HP{ .val = 1.000000e-283, .off = 5.314789322934508480e-300 },
598 HP{ .val = 1.000000e-284, .off = -3.644541414696392675e-301 },
599 HP{ .val = 1.000000e-285, .off = -7.377595888709267777e-302 },
600 HP{ .val = 1.000000e-286, .off = -5.044436842451220838e-303 },
601 HP{ .val = 1.000000e-287, .off = -2.127988034628661760e-304 },
602 HP{ .val = 1.000000e-288, .off = -5.773549044406860911e-305 },
603 HP{ .val = 1.000000e-289, .off = -1.216597782184112068e-306 },
604 HP{ .val = 1.000000e-290, .off = -6.912786859962547924e-307 },
605 HP{ .val = 1.000000e-291, .off = 3.767567660872018813e-308 },
606606};
std/fmt/index.zig+38-32
......@@ -107,7 +107,7 @@ pub fn format(context: var, comptime Errors: type, output: fn(@typeOf(context),
107107 '}' => {
108108 return output(context, args[next_arg]);
109109 },
110 '0' ... '9' => {
110 '0'...'9' => {
111111 width_start = i;
112112 state = State.BufWidth;
113113 },
......@@ -127,7 +127,7 @@ pub fn format(context: var, comptime Errors: type, output: fn(@typeOf(context),
127127 state = State.Start;
128128 start_index = i + 1;
129129 },
130 '0' ... '9' => {
130 '0'...'9' => {
131131 width_start = i;
132132 state = State.IntegerWidth;
133133 },
......@@ -141,7 +141,7 @@ pub fn format(context: var, comptime Errors: type, output: fn(@typeOf(context),
141141 state = State.Start;
142142 start_index = i + 1;
143143 },
144 '0' ... '9' => {},
144 '0'...'9' => {},
145145 else => @compileError("Unexpected character in format string: " ++ []u8{c}),
146146 },
147147 State.FloatScientific => switch (c) {
......@@ -151,7 +151,7 @@ pub fn format(context: var, comptime Errors: type, output: fn(@typeOf(context),
151151 state = State.Start;
152152 start_index = i + 1;
153153 },
154 '0' ... '9' => {
154 '0'...'9' => {
155155 width_start = i;
156156 state = State.FloatScientificWidth;
157157 },
......@@ -165,7 +165,7 @@ pub fn format(context: var, comptime Errors: type, output: fn(@typeOf(context),
165165 state = State.Start;
166166 start_index = i + 1;
167167 },
168 '0' ... '9' => {},
168 '0'...'9' => {},
169169 else => @compileError("Unexpected character in format string: " ++ []u8{c}),
170170 },
171171 State.Float => switch (c) {
......@@ -175,7 +175,7 @@ pub fn format(context: var, comptime Errors: type, output: fn(@typeOf(context),
175175 state = State.Start;
176176 start_index = i + 1;
177177 },
178 '0' ... '9' => {
178 '0'...'9' => {
179179 width_start = i;
180180 state = State.FloatWidth;
181181 },
......@@ -189,7 +189,7 @@ pub fn format(context: var, comptime Errors: type, output: fn(@typeOf(context),
189189 state = State.Start;
190190 start_index = i + 1;
191191 },
192 '0' ... '9' => {},
192 '0'...'9' => {},
193193 else => @compileError("Unexpected character in format string: " ++ []u8{c}),
194194 },
195195 State.BufWidth => switch (c) {
......@@ -200,7 +200,7 @@ pub fn format(context: var, comptime Errors: type, output: fn(@typeOf(context),
200200 state = State.Start;
201201 start_index = i + 1;
202202 },
203 '0' ... '9' => {},
203 '0'...'9' => {},
204204 else => @compileError("Unexpected character in format string: " ++ []u8{c}),
205205 },
206206 State.Character => switch (c) {
......@@ -223,7 +223,7 @@ pub fn format(context: var, comptime Errors: type, output: fn(@typeOf(context),
223223 radix = 1024;
224224 state = State.BytesBase;
225225 },
226 '0' ... '9' => {
226 '0'...'9' => {
227227 width_start = i;
228228 state = State.BytesWidth;
229229 },
......@@ -236,7 +236,7 @@ pub fn format(context: var, comptime Errors: type, output: fn(@typeOf(context),
236236 state = State.Start;
237237 start_index = i + 1;
238238 },
239 '0' ... '9' => {
239 '0'...'9' => {
240240 width_start = i;
241241 state = State.BytesWidth;
242242 },
......@@ -250,7 +250,7 @@ pub fn format(context: var, comptime Errors: type, output: fn(@typeOf(context),
250250 state = State.Start;
251251 start_index = i + 1;
252252 },
253 '0' ... '9' => {},
253 '0'...'9' => {},
254254 else => @compileError("Unexpected character in format string: " ++ []u8{c}),
255255 },
256256 }
......@@ -562,9 +562,14 @@ pub fn formatFloatDecimal(value: var, maybe_precision: ?usize, context: var, com
562562 }
563563}
564564
565pub fn formatBytes(value: var, width: ?usize, comptime radix: usize,
566 context: var, comptime Errors: type, output: fn(@typeOf(context), []const u8)Errors!void) Errors!void
567{
565pub fn formatBytes(
566 value: var,
567 width: ?usize,
568 comptime radix: usize,
569 context: var,
570 comptime Errors: type,
571 output: fn(@typeOf(context), []const u8) Errors!void,
572) Errors!void {
568573 if (value == 0) {
569574 return output(context, "0B");
570575 }
......@@ -585,16 +590,22 @@ pub fn formatBytes(value: var, width: ?usize, comptime radix: usize,
585590 }
586591
587592 const buf = switch (radix) {
588 1000 => []u8 { suffix, 'B' },
589 1024 => []u8 { suffix, 'i', 'B' },
593 1000 => []u8{ suffix, 'B' },
594 1024 => []u8{ suffix, 'i', 'B' },
590595 else => unreachable,
591596 };
592597 return output(context, buf);
593598}
594599
595pub fn formatInt(value: var, base: u8, uppercase: bool, width: usize,
596 context: var, comptime Errors: type, output: fn(@typeOf(context), []const u8)Errors!void) Errors!void
597{
600pub fn formatInt(
601 value: var,
602 base: u8,
603 uppercase: bool,
604 width: usize,
605 context: var,
606 comptime Errors: type,
607 output: fn(@typeOf(context), []const u8) Errors!void,
608) Errors!void {
598609 if (@typeOf(value).is_signed) {
599610 return formatIntSigned(value, base, uppercase, width, context, Errors, output);
600611 } else {
......@@ -717,9 +728,9 @@ pub fn parseUnsigned(comptime T: type, buf: []const u8, radix: u8) ParseUnsigned
717728
718729pub fn charToDigit(c: u8, radix: u8) (error{InvalidCharacter}!u8) {
719730 const value = switch (c) {
720 '0' ... '9' => c - '0',
721 'A' ... 'Z' => c - 'A' + 10,
722 'a' ... 'z' => c - 'a' + 10,
731 '0'...'9' => c - '0',
732 'A'...'Z' => c - 'A' + 10,
733 'a'...'z' => c - 'a' + 10,
723734 else => return error.InvalidCharacter,
724735 };
725736
......@@ -730,8 +741,8 @@ pub fn charToDigit(c: u8, radix: u8) (error{InvalidCharacter}!u8) {
730741
731742fn digitToChar(digit: u8, uppercase: bool) u8 {
732743 return switch (digit) {
733 0 ... 9 => digit + '0',
734 10 ... 35 => digit + ((if (uppercase) u8('A') else u8('a')) - 10),
744 0...9 => digit + '0',
745 10...35 => digit + ((if (uppercase) u8('A') else u8('a')) - 10),
735746 else => unreachable,
736747 };
737748}
......@@ -754,8 +765,7 @@ pub fn bufPrint(buf: []u8, comptime fmt: []const u8, args: ...) ![]u8 {
754765
755766pub fn allocPrint(allocator: &mem.Allocator, comptime fmt: []const u8, args: ...) ![]u8 {
756767 var size: usize = 0;
757 format(&size, error{}, countSize, fmt, args) catch |err| switch (err) {
758 };
768 format(&size, error{}, countSize, fmt, args) catch |err| switch (err) {};
759769 const buf = try allocator.alloc(u8, size);
760770 return bufPrint(buf, fmt, args);
761771}
......@@ -1043,8 +1053,7 @@ test "fmt.format" {
10431053fn testFmt(expected: []const u8, comptime template: []const u8, args: ...) !void {
10441054 var buf: [100]u8 = undefined;
10451055 const result = try bufPrint(buf[0..], template, args);
1046 if (mem.eql(u8, result, expected))
1047 return;
1056 if (mem.eql(u8, result, expected)) return;
10481057
10491058 std.debug.warn("\n====== expected this output: =========\n");
10501059 std.debug.warn("{}", expected);
......@@ -1082,10 +1091,7 @@ test "fmt.trim" {
10821091
10831092pub fn isWhiteSpace(byte: u8) bool {
10841093 return switch (byte) {
1085 ' ',
1086 '\t',
1087 '\n',
1088 '\r' => true,
1094 ' ', '\t', '\n', '\r' => true,
10891095 else => false,
10901096 };
10911097}
std/hash/adler.zig+6-11
......@@ -13,9 +13,7 @@ pub const Adler32 = struct {
1313 adler: u32,
1414
1515 pub fn init() Adler32 {
16 return Adler32 {
17 .adler = 1,
18 };
16 return Adler32{ .adler = 1 };
1917 }
2018
2119 // This fast variant is taken from zlib. It reduces the required modulos and unrolls longer
......@@ -33,8 +31,7 @@ pub const Adler32 = struct {
3331 if (s2 >= base) {
3432 s2 -= base;
3533 }
36 }
37 else if (input.len < 16) {
34 } else if (input.len < 16) {
3835 for (input) |b| {
3936 s1 +%= b;
4037 s2 +%= s1;
......@@ -44,8 +41,7 @@ pub const Adler32 = struct {
4441 }
4542
4643 s2 %= base;
47 }
48 else {
44 } else {
4945 var i: usize = 0;
5046 while (i + nmax <= input.len) : (i += nmax) {
5147 const n = nmax / 16; // note: 16 | nmax
......@@ -98,15 +94,14 @@ test "adler32 sanity" {
9894}
9995
10096test "adler32 long" {
101 const long1 = []u8 {1} ** 1024;
97 const long1 = []u8{1} ** 1024;
10298 debug.assert(Adler32.hash(long1[0..]) == 0x06780401);
10399
104 const long2 = []u8 {1} ** 1025;
100 const long2 = []u8{1} ** 1025;
105101 debug.assert(Adler32.hash(long2[0..]) == 0x0a7a0402);
106102}
107103
108104test "adler32 very long" {
109 const long = []u8 {1} ** 5553;
105 const long = []u8{1} ** 5553;
110106 debug.assert(Adler32.hash(long[0..]) == 0x707f15b2);
111107}
112
std/hash/crc.zig+2-3
......@@ -69,7 +69,6 @@ pub fn Crc32WithPoly(comptime poly: u32) type {
6969 self.crc ^= (u32(p[2]) << 16);
7070 self.crc ^= (u32(p[3]) << 24);
7171
72
7372 self.crc =
7473 lookup_tables[0][p[7]] ^
7574 lookup_tables[1][p[6]] ^
......@@ -77,8 +76,8 @@ pub fn Crc32WithPoly(comptime poly: u32) type {
7776 lookup_tables[3][p[4]] ^
7877 lookup_tables[4][@truncate(u8, self.crc >> 24)] ^
7978 lookup_tables[5][@truncate(u8, self.crc >> 16)] ^
80 lookup_tables[6][@truncate(u8, self.crc >> 8)] ^
81 lookup_tables[7][@truncate(u8, self.crc >> 0)];
79 lookup_tables[6][@truncate(u8, self.crc >> 8)] ^
80 lookup_tables[7][@truncate(u8, self.crc >> 0)];
8281 }
8382
8483 while (i < input.len) : (i += 1) {
std/hash/fnv.zig+2-4
......@@ -7,7 +7,7 @@
77const std = @import("../index.zig");
88const debug = std.debug;
99
10pub const Fnv1a_32 = Fnv1a(u32, 0x01000193 , 0x811c9dc5);
10pub const Fnv1a_32 = Fnv1a(u32, 0x01000193, 0x811c9dc5);
1111pub const Fnv1a_64 = Fnv1a(u64, 0x100000001b3, 0xcbf29ce484222325);
1212pub const Fnv1a_128 = Fnv1a(u128, 0x1000000000000000000013b, 0x6c62272e07bb014262b821756295c58d);
1313
......@@ -18,9 +18,7 @@ fn Fnv1a(comptime T: type, comptime prime: T, comptime offset: T) type {
1818 value: T,
1919
2020 pub fn init() Self {
21 return Self {
22 .value = offset,
23 };
21 return Self{ .value = offset };
2422 }
2523
2624 pub fn update(self: &Self, input: []const u8) void {
std/hash/siphash.zig+3-3
......@@ -45,7 +45,7 @@ fn SipHash(comptime T: type, comptime c_rounds: usize, comptime d_rounds: usize)
4545 const k0 = mem.readInt(key[0..8], u64, Endian.Little);
4646 const k1 = mem.readInt(key[8..16], u64, Endian.Little);
4747
48 var d = Self {
48 var d = Self{
4949 .v0 = k0 ^ 0x736f6d6570736575,
5050 .v1 = k1 ^ 0x646f72616e646f6d,
5151 .v2 = k0 ^ 0x6c7967656e657261,
......@@ -162,7 +162,7 @@ fn SipHash(comptime T: type, comptime c_rounds: usize, comptime d_rounds: usize)
162162const test_key = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f";
163163
164164test "siphash64-2-4 sanity" {
165 const vectors = [][]const u8 {
165 const vectors = [][]const u8{
166166 "\x31\x0e\x0e\xdd\x47\xdb\x6f\x72", // ""
167167 "\xfd\x67\xdc\x93\xc5\x39\xf8\x74", // "\x00"
168168 "\x5a\x4f\xa9\xd9\x09\x80\x6c\x0d", // "\x00\x01" ... etc
......@@ -241,7 +241,7 @@ test "siphash64-2-4 sanity" {
241241}
242242
243243test "siphash128-2-4 sanity" {
244 const vectors = [][]const u8 {
244 const vectors = [][]const u8{
245245 "\xa3\x81\x7f\x04\xba\x25\xa8\xe6\x6d\xf6\x72\x14\xc7\x55\x02\x93",
246246 "\xda\x87\xc1\xd8\x6b\x99\xaf\x44\x34\x76\x59\x11\x9b\x22\xfc\x45",
247247 "\x81\x77\x22\x8d\xa4\xa4\x5d\xc7\xfc\xa3\x8b\xde\xf6\x0a\xff\xe4",
std/heap.zig+4-10
......@@ -68,9 +68,7 @@ pub const DirectAllocator = struct {
6868 const self = @fieldParentPtr(DirectAllocator, "allocator", allocator);
6969
7070 switch (builtin.os) {
71 Os.linux,
72 Os.macosx,
73 Os.ios => {
71 Os.linux, Os.macosx, Os.ios => {
7472 const p = os.posix;
7573 const alloc_size = if (alignment <= os.page_size) n else n + alignment;
7674 const addr = p.mmap(null, alloc_size, p.PROT_READ | p.PROT_WRITE, p.MAP_PRIVATE | p.MAP_ANONYMOUS, -1, 0);
......@@ -121,9 +119,7 @@ pub const DirectAllocator = struct {
121119 const self = @fieldParentPtr(DirectAllocator, "allocator", allocator);
122120
123121 switch (builtin.os) {
124 Os.linux,
125 Os.macosx,
126 Os.ios => {
122 Os.linux, Os.macosx, Os.ios => {
127123 if (new_size <= old_mem.len) {
128124 const base_addr = @ptrToInt(old_mem.ptr);
129125 const old_addr_end = base_addr + old_mem.len;
......@@ -168,9 +164,7 @@ pub const DirectAllocator = struct {
168164 const self = @fieldParentPtr(DirectAllocator, "allocator", allocator);
169165
170166 switch (builtin.os) {
171 Os.linux,
172 Os.macosx,
173 Os.ios => {
167 Os.linux, Os.macosx, Os.ios => {
174168 _ = os.posix.munmap(@ptrToInt(bytes.ptr), bytes.len);
175169 },
176170 Os.windows => {
......@@ -430,7 +424,7 @@ fn testAllocator(allocator: &mem.Allocator) !void {
430424}
431425
432426fn testAllocatorLargeAlignment(allocator: &mem.Allocator) mem.Allocator.Error!void {
433 //Maybe a platform's page_size is actually the same as or
427 //Maybe a platform's page_size is actually the same as or
434428 // very near usize?
435429 if (os.page_size << 2 > @maxValue(usize)) return;
436430
std/io_test.zig+1-1
......@@ -42,7 +42,7 @@ test "write a file, read it, then delete it" {
4242
4343 assert(mem.eql(u8, contents[0.."begin".len], "begin"));
4444 assert(mem.eql(u8, contents["begin".len..contents.len - "end".len], data));
45 assert(mem.eql(u8, contents[contents.len - "end".len ..], "end"));
45 assert(mem.eql(u8, contents[contents.len - "end".len..], "end"));
4646 }
4747 try os.deleteFile(allocator, tmp_file_name);
4848}
std/json.zig+32-74
......@@ -252,7 +252,7 @@ pub const StreamingJsonParser = struct {
252252 p.after_value_state = State.TopLevelEnd;
253253 p.count = 0;
254254 },
255 '1' ... '9' => {
255 '1'...'9' => {
256256 p.number_is_integer = true;
257257 p.state = State.NumberMaybeDigitOrDotOrExponent;
258258 p.after_value_state = State.TopLevelEnd;
......@@ -281,10 +281,7 @@ pub const StreamingJsonParser = struct {
281281 p.after_value_state = State.TopLevelEnd;
282282 p.count = 0;
283283 },
284 0x09,
285 0x0A,
286 0x0D,
287 0x20 => {
284 0x09, 0x0A, 0x0D, 0x20 => {
288285 // whitespace
289286 },
290287 else => {
......@@ -293,10 +290,7 @@ pub const StreamingJsonParser = struct {
293290 },
294291
295292 State.TopLevelEnd => switch (c) {
296 0x09,
297 0x0A,
298 0x0D,
299 0x20 => {
293 0x09, 0x0A, 0x0D, 0x20 => {
300294 // whitespace
301295 },
302296 else => {
......@@ -392,7 +386,7 @@ pub const StreamingJsonParser = struct {
392386 p.state = State.NumberMaybeDotOrExponent;
393387 p.count = 0;
394388 },
395 '1' ... '9' => {
389 '1'...'9' => {
396390 p.state = State.NumberMaybeDigitOrDotOrExponent;
397391 p.count = 0;
398392 },
......@@ -412,10 +406,7 @@ pub const StreamingJsonParser = struct {
412406 p.state = State.NullLiteral1;
413407 p.count = 0;
414408 },
415 0x09,
416 0x0A,
417 0x0D,
418 0x20 => {
409 0x09, 0x0A, 0x0D, 0x20 => {
419410 // whitespace
420411 },
421412 else => {
......@@ -461,7 +452,7 @@ pub const StreamingJsonParser = struct {
461452 p.state = State.NumberMaybeDotOrExponent;
462453 p.count = 0;
463454 },
464 '1' ... '9' => {
455 '1'...'9' => {
465456 p.state = State.NumberMaybeDigitOrDotOrExponent;
466457 p.count = 0;
467458 },
......@@ -481,10 +472,7 @@ pub const StreamingJsonParser = struct {
481472 p.state = State.NullLiteral1;
482473 p.count = 0;
483474 },
484 0x09,
485 0x0A,
486 0x0D,
487 0x20 => {
475 0x09, 0x0A, 0x0D, 0x20 => {
488476 // whitespace
489477 },
490478 else => {
......@@ -533,10 +521,7 @@ pub const StreamingJsonParser = struct {
533521
534522 token.* = Token.initMarker(Token.Id.ObjectEnd);
535523 },
536 0x09,
537 0x0A,
538 0x0D,
539 0x20 => {
524 0x09, 0x0A, 0x0D, 0x20 => {
540525 // whitespace
541526 },
542527 else => {
......@@ -549,10 +534,7 @@ pub const StreamingJsonParser = struct {
549534 p.state = State.ValueBegin;
550535 p.after_string_state = State.ValueEnd;
551536 },
552 0x09,
553 0x0A,
554 0x0D,
555 0x20 => {
537 0x09, 0x0A, 0x0D, 0x20 => {
556538 // whitespace
557539 },
558540 else => {
......@@ -561,7 +543,7 @@ pub const StreamingJsonParser = struct {
561543 },
562544
563545 State.String => switch (c) {
564 0x00 ... 0x1F => {
546 0x00...0x1F => {
565547 return error.InvalidControlCharacter;
566548 },
567549 '"' => {
......@@ -576,19 +558,16 @@ pub const StreamingJsonParser = struct {
576558 '\\' => {
577559 p.state = State.StringEscapeCharacter;
578560 },
579 0x20,
580 0x21,
581 0x23 ... 0x5B,
582 0x5D ... 0x7F => {
561 0x20, 0x21, 0x23...0x5B, 0x5D...0x7F => {
583562 // non-control ascii
584563 },
585 0xC0 ... 0xDF => {
564 0xC0...0xDF => {
586565 p.state = State.StringUtf8Byte1;
587566 },
588 0xE0 ... 0xEF => {
567 0xE0...0xEF => {
589568 p.state = State.StringUtf8Byte2;
590569 },
591 0xF0 ... 0xFF => {
570 0xF0...0xFF => {
592571 p.state = State.StringUtf8Byte3;
593572 },
594573 else => {
......@@ -620,14 +599,7 @@ pub const StreamingJsonParser = struct {
620599 // The current JSONTestSuite tests rely on both of this behaviour being present
621600 // however, so we default to the status quo where both are accepted until this
622601 // is further clarified.
623 '"',
624 '\\',
625 '/',
626 'b',
627 'f',
628 'n',
629 'r',
630 't' => {
602 '"', '\\', '/', 'b', 'f', 'n', 'r', 't' => {
631603 p.string_has_escape = true;
632604 p.state = State.String;
633605 },
......@@ -641,36 +613,28 @@ pub const StreamingJsonParser = struct {
641613 },
642614
643615 State.StringEscapeHexUnicode4 => switch (c) {
644 '0' ... '9',
645 'A' ... 'F',
646 'a' ... 'f' => {
616 '0'...'9', 'A'...'F', 'a'...'f' => {
647617 p.state = State.StringEscapeHexUnicode3;
648618 },
649619 else => return error.InvalidUnicodeHexSymbol,
650620 },
651621
652622 State.StringEscapeHexUnicode3 => switch (c) {
653 '0' ... '9',
654 'A' ... 'F',
655 'a' ... 'f' => {
623 '0'...'9', 'A'...'F', 'a'...'f' => {
656624 p.state = State.StringEscapeHexUnicode2;
657625 },
658626 else => return error.InvalidUnicodeHexSymbol,
659627 },
660628
661629 State.StringEscapeHexUnicode2 => switch (c) {
662 '0' ... '9',
663 'A' ... 'F',
664 'a' ... 'f' => {
630 '0'...'9', 'A'...'F', 'a'...'f' => {
665631 p.state = State.StringEscapeHexUnicode1;
666632 },
667633 else => return error.InvalidUnicodeHexSymbol,
668634 },
669635
670636 State.StringEscapeHexUnicode1 => switch (c) {
671 '0' ... '9',
672 'A' ... 'F',
673 'a' ... 'f' => {
637 '0'...'9', 'A'...'F', 'a'...'f' => {
674638 p.state = State.String;
675639 },
676640 else => return error.InvalidUnicodeHexSymbol,
......@@ -682,7 +646,7 @@ pub const StreamingJsonParser = struct {
682646 '0' => {
683647 p.state = State.NumberMaybeDotOrExponent;
684648 },
685 '1' ... '9' => {
649 '1'...'9' => {
686650 p.state = State.NumberMaybeDigitOrDotOrExponent;
687651 },
688652 else => {
......@@ -698,8 +662,7 @@ pub const StreamingJsonParser = struct {
698662 p.number_is_integer = false;
699663 p.state = State.NumberFractionalRequired;
700664 },
701 'e',
702 'E' => {
665 'e', 'E' => {
703666 p.number_is_integer = false;
704667 p.state = State.NumberExponent;
705668 },
......@@ -718,12 +681,11 @@ pub const StreamingJsonParser = struct {
718681 p.number_is_integer = false;
719682 p.state = State.NumberFractionalRequired;
720683 },
721 'e',
722 'E' => {
684 'e', 'E' => {
723685 p.number_is_integer = false;
724686 p.state = State.NumberExponent;
725687 },
726 '0' ... '9' => {
688 '0'...'9' => {
727689 // another digit
728690 },
729691 else => {
......@@ -737,7 +699,7 @@ pub const StreamingJsonParser = struct {
737699 State.NumberFractionalRequired => {
738700 p.complete = p.after_value_state == State.TopLevelEnd;
739701 switch (c) {
740 '0' ... '9' => {
702 '0'...'9' => {
741703 p.state = State.NumberFractional;
742704 },
743705 else => {
......@@ -749,11 +711,10 @@ pub const StreamingJsonParser = struct {
749711 State.NumberFractional => {
750712 p.complete = p.after_value_state == State.TopLevelEnd;
751713 switch (c) {
752 '0' ... '9' => {
714 '0'...'9' => {
753715 // another digit
754716 },
755 'e',
756 'E' => {
717 'e', 'E' => {
757718 p.number_is_integer = false;
758719 p.state = State.NumberExponent;
759720 },
......@@ -768,8 +729,7 @@ pub const StreamingJsonParser = struct {
768729 State.NumberMaybeExponent => {
769730 p.complete = p.after_value_state == State.TopLevelEnd;
770731 switch (c) {
771 'e',
772 'E' => {
732 'e', 'E' => {
773733 p.number_is_integer = false;
774734 p.state = State.NumberExponent;
775735 },
......@@ -782,12 +742,11 @@ pub const StreamingJsonParser = struct {
782742 },
783743
784744 State.NumberExponent => switch (c) {
785 '-',
786 '+' => {
745 '-', '+' => {
787746 p.complete = false;
788747 p.state = State.NumberExponentDigitsRequired;
789748 },
790 '0' ... '9' => {
749 '0'...'9' => {
791750 p.complete = p.after_value_state == State.TopLevelEnd;
792751 p.state = State.NumberExponentDigits;
793752 },
......@@ -797,7 +756,7 @@ pub const StreamingJsonParser = struct {
797756 },
798757
799758 State.NumberExponentDigitsRequired => switch (c) {
800 '0' ... '9' => {
759 '0'...'9' => {
801760 p.complete = p.after_value_state == State.TopLevelEnd;
802761 p.state = State.NumberExponentDigits;
803762 },
......@@ -809,7 +768,7 @@ pub const StreamingJsonParser = struct {
809768 State.NumberExponentDigits => {
810769 p.complete = p.after_value_state == State.TopLevelEnd;
811770 switch (c) {
812 '0' ... '9' => {
771 '0'...'9' => {
813772 // another digit
814773 },
815774 else => {
......@@ -1257,8 +1216,7 @@ pub const JsonParser = struct {
12571216 Token.Id.Null => {
12581217 try p.stack.append(Value.Null);
12591218 },
1260 Token.Id.ObjectEnd,
1261 Token.Id.ArrayEnd => {
1219 Token.Id.ObjectEnd, Token.Id.ArrayEnd => {
12621220 unreachable;
12631221 },
12641222 },
std/macho.zig+11-9
......@@ -58,15 +58,15 @@ pub const SymbolTable = struct {
5858 // code, its displacement is different.
5959 pub fn deinit(self: &SymbolTable) void {
6060 self.allocator.free(self.symbols);
61 self.symbols = []const Symbol {};
61 self.symbols = []const Symbol{};
6262
6363 self.allocator.free(self.strings);
64 self.strings = []const u8 {};
64 self.strings = []const u8{};
6565 }
6666
6767 pub fn search(self: &const SymbolTable, address: usize) ?&const Symbol {
6868 var min: usize = 0;
69 var max: usize = self.symbols.len - 1; // Exclude sentinel.
69 var max: usize = self.symbols.len - 1; // Exclude sentinel.
7070 while (min < max) {
7171 const mid = min + (max - min) / 2;
7272 const curr = &self.symbols[mid];
......@@ -118,10 +118,11 @@ pub fn loadSymbols(allocator: &mem.Allocator, in: &io.FileInStream) !SymbolTable
118118 try in.stream.readNoEof(strings);
119119
120120 var nsyms: usize = 0;
121 for (syms) |sym| if (isSymbol(sym)) nsyms += 1;
121 for (syms) |sym|
122 if (isSymbol(sym)) nsyms += 1;
122123 if (nsyms == 0) return error.MissingDebugInfo;
123124
124 var symbols = try allocator.alloc(Symbol, nsyms + 1); // Room for sentinel.
125 var symbols = try allocator.alloc(Symbol, nsyms + 1); // Room for sentinel.
125126 errdefer allocator.free(symbols);
126127
127128 var pie_slide: usize = 0;
......@@ -132,7 +133,7 @@ pub fn loadSymbols(allocator: &mem.Allocator, in: &io.FileInStream) !SymbolTable
132133 const end = ??mem.indexOfScalarPos(u8, strings, start, 0);
133134 const name = strings[start..end];
134135 const address = sym.n_value;
135 symbols[nsym] = Symbol { .name = name, .address = address };
136 symbols[nsym] = Symbol{ .name = name, .address = address };
136137 nsym += 1;
137138 if (is_pie and mem.eql(u8, name, "_SymbolTable_deinit")) {
138139 pie_slide = @ptrToInt(SymbolTable.deinit) - address;
......@@ -145,13 +146,14 @@ pub fn loadSymbols(allocator: &mem.Allocator, in: &io.FileInStream) !SymbolTable
145146 // Insert the sentinel. Since we don't know where the last function ends,
146147 // we arbitrarily limit it to the start address + 4 KB.
147148 const top = symbols[nsyms - 1].address + 4096;
148 symbols[nsyms] = Symbol { .name = "", .address = top };
149 symbols[nsyms] = Symbol{ .name = "", .address = top };
149150
150151 if (pie_slide != 0) {
151 for (symbols) |*symbol| symbol.address += pie_slide;
152 for (symbols) |*symbol|
153 symbol.address += pie_slide;
152154 }
153155
154 return SymbolTable {
156 return SymbolTable{
155157 .allocator = allocator,
156158 .symbols = symbols,
157159 .strings = strings,
std/math/atan.zig+15-17
......@@ -17,25 +17,25 @@ pub fn atan(x: var) @typeOf(x) {
1717}
1818
1919fn atan32(x_: f32) f32 {
20 const atanhi = []const f32 {
20 const atanhi = []const f32{
2121 4.6364760399e-01, // atan(0.5)hi
2222 7.8539812565e-01, // atan(1.0)hi
2323 9.8279368877e-01, // atan(1.5)hi
2424 1.5707962513e+00, // atan(inf)hi
2525 };
2626
27 const atanlo = []const f32 {
27 const atanlo = []const f32{
2828 5.0121582440e-09, // atan(0.5)lo
2929 3.7748947079e-08, // atan(1.0)lo
3030 3.4473217170e-08, // atan(1.5)lo
3131 7.5497894159e-08, // atan(inf)lo
3232 };
3333
34 const aT = []const f32 {
34 const aT = []const f32{
3535 3.3333328366e-01,
36 -1.9999158382e-01,
36 -1.9999158382e-01,
3737 1.4253635705e-01,
38 -1.0648017377e-01,
38 -1.0648017377e-01,
3939 6.1687607318e-02,
4040 };
4141
......@@ -80,8 +80,7 @@ fn atan32(x_: f32) f32 {
8080 id = 1;
8181 x = (x - 1.0) / (x + 1.0);
8282 }
83 }
84 else {
83 } else {
8584 // |x| < 2.4375
8685 if (ix < 0x401C0000) {
8786 id = 2;
......@@ -109,31 +108,31 @@ fn atan32(x_: f32) f32 {
109108}
110109
111110fn atan64(x_: f64) f64 {
112 const atanhi = []const f64 {
111 const atanhi = []const f64{
113112 4.63647609000806093515e-01, // atan(0.5)hi
114113 7.85398163397448278999e-01, // atan(1.0)hi
115114 9.82793723247329054082e-01, // atan(1.5)hi
116115 1.57079632679489655800e+00, // atan(inf)hi
117116 };
118117
119 const atanlo = []const f64 {
118 const atanlo = []const f64{
120119 2.26987774529616870924e-17, // atan(0.5)lo
121120 3.06161699786838301793e-17, // atan(1.0)lo
122121 1.39033110312309984516e-17, // atan(1.5)lo
123122 6.12323399573676603587e-17, // atan(inf)lo
124123 };
125124
126 const aT = []const f64 {
125 const aT = []const f64{
127126 3.33333333333329318027e-01,
128 -1.99999999998764832476e-01,
127 -1.99999999998764832476e-01,
129128 1.42857142725034663711e-01,
130 -1.11111104054623557880e-01,
129 -1.11111104054623557880e-01,
131130 9.09088713343650656196e-02,
132 -7.69187620504482999495e-02,
131 -7.69187620504482999495e-02,
133132 6.66107313738753120669e-02,
134 -5.83357013379057348645e-02,
133 -5.83357013379057348645e-02,
135134 4.97687799461593236017e-02,
136 -3.65315727442169155270e-02,
135 -3.65315727442169155270e-02,
137136 1.62858201153657823623e-02,
138137 };
139138
......@@ -179,8 +178,7 @@ fn atan64(x_: f64) f64 {
179178 id = 1;
180179 x = (x - 1.0) / (x + 1.0);
181180 }
182 }
183 else {
181 } else {
184182 // |x| < 2.4375
185183 if (ix < 0x40038000) {
186184 id = 2;
std/math/atan2.zig+2-4
......@@ -53,8 +53,7 @@ fn atan2_32(y: f32, x: f32) f32 {
5353
5454 if (iy == 0) {
5555 switch (m) {
56 0,
57 1 => return y, // atan(+-0, +...)
56 0, 1 => return y, // atan(+-0, +...)
5857 2 => return pi, // atan(+0, -...)
5958 3 => return -pi, // atan(-0, -...)
6059 else => unreachable,
......@@ -144,8 +143,7 @@ fn atan2_64(y: f64, x: f64) f64 {
144143
145144 if (iy | ly == 0) {
146145 switch (m) {
147 0,
148 1 => return y, // atan(+-0, +...)
146 0, 1 => return y, // atan(+-0, +...)
149147 2 => return pi, // atan(+0, -...)
150148 3 => return -pi, // atan(-0, -...)
151149 else => unreachable,
std/math/complex/index.zig+11-11
......@@ -31,28 +31,28 @@ pub fn Complex(comptime T: type) type {
3131 im: T,
3232
3333 pub fn new(re: T, im: T) Self {
34 return Self {
34 return Self{
3535 .re = re,
3636 .im = im,
3737 };
3838 }
3939
4040 pub fn add(self: &const Self, other: &const Self) Self {
41 return Self {
41 return Self{
4242 .re = self.re + other.re,
4343 .im = self.im + other.im,
4444 };
4545 }
4646
4747 pub fn sub(self: &const Self, other: &const Self) Self {
48 return Self {
48 return Self{
4949 .re = self.re - other.re,
5050 .im = self.im - other.im,
5151 };
5252 }
5353
5454 pub fn mul(self: &const Self, other: &const Self) Self {
55 return Self {
55 return Self{
5656 .re = self.re * other.re - self.im * other.im,
5757 .im = self.im * other.re + self.re * other.im,
5858 };
......@@ -63,14 +63,14 @@ pub fn Complex(comptime T: type) type {
6363 const im_num = self.im * other.re - self.re * other.im;
6464 const den = other.re * other.re + other.im * other.im;
6565
66 return Self {
66 return Self{
6767 .re = re_num / den,
6868 .im = im_num / den,
6969 };
7070 }
7171
7272 pub fn conjugate(self: &const Self) Self {
73 return Self {
73 return Self{
7474 .re = self.re,
7575 .im = -self.im,
7676 };
......@@ -78,7 +78,7 @@ pub fn Complex(comptime T: type) type {
7878
7979 pub fn reciprocal(self: &const Self) Self {
8080 const m = self.re * self.re + self.im * self.im;
81 return Self {
81 return Self{
8282 .re = self.re / m,
8383 .im = -self.im / m,
8484 };
......@@ -121,8 +121,8 @@ test "complex.div" {
121121 const b = Complex(f32).new(2, 7);
122122 const c = a.div(b);
123123
124 debug.assert(math.approxEq(f32, c.re, f32(31)/53, epsilon) and
125 math.approxEq(f32, c.im, f32(-29)/53, epsilon));
124 debug.assert(math.approxEq(f32, c.re, f32(31) / 53, epsilon) and
125 math.approxEq(f32, c.im, f32(-29) / 53, epsilon));
126126}
127127
128128test "complex.conjugate" {
......@@ -136,8 +136,8 @@ test "complex.reciprocal" {
136136 const a = Complex(f32).new(5, 3);
137137 const c = a.reciprocal();
138138
139 debug.assert(math.approxEq(f32, c.re, f32(5)/34, epsilon) and
140 math.approxEq(f32, c.im, f32(-3)/34, epsilon));
139 debug.assert(math.approxEq(f32, c.re, f32(5) / 34, epsilon) and
140 math.approxEq(f32, c.im, f32(-3) / 34, epsilon));
141141}
142142
143143test "complex.magnitude" {
std/math/complex/tanh.zig+2-2
......@@ -98,7 +98,7 @@ test "complex.ctanh32" {
9898 const a = Complex(f32).new(5, 3);
9999 const c = tanh(a);
100100
101 debug.assert(math.approxEq(f32, c.re, 0.999913, epsilon));
101 debug.assert(math.approxEq(f32, c.re, 0.999913, epsilon));
102102 debug.assert(math.approxEq(f32, c.im, -0.000025, epsilon));
103103}
104104
......@@ -106,6 +106,6 @@ test "complex.ctanh64" {
106106 const a = Complex(f64).new(5, 3);
107107 const c = tanh(a);
108108
109 debug.assert(math.approxEq(f64, c.re, 0.999913, epsilon));
109 debug.assert(math.approxEq(f64, c.re, 0.999913, epsilon));
110110 debug.assert(math.approxEq(f64, c.im, -0.000025, epsilon));
111111}
std/math/exp.zig+13-17
......@@ -20,10 +20,10 @@ pub fn exp(x: var) @typeOf(x) {
2020fn exp32(x_: f32) f32 {
2121 @setFloatMode(this, builtin.FloatMode.Strict);
2222
23 const half = []f32 { 0.5, -0.5 };
23 const half = []f32{ 0.5, -0.5 };
2424 const ln2hi = 6.9314575195e-1;
2525 const ln2lo = 1.4286067653e-6;
26 const invln2 = 1.4426950216e+0;
26 const invln2 = 1.4426950216e+0;
2727 const P1 = 1.6666625440e-1;
2828 const P2 = -2.7667332906e-3;
2929
......@@ -47,7 +47,7 @@ fn exp32(x_: f32) f32 {
4747 return x * 0x1.0p127;
4848 }
4949 if (sign != 0) {
50 math.forceEval(-0x1.0p-149 / x); // overflow
50 math.forceEval(-0x1.0p-149 / x); // overflow
5151 // x <= -103.972084
5252 if (hx >= 0x42CFF1B5) {
5353 return 0;
......@@ -64,8 +64,7 @@ fn exp32(x_: f32) f32 {
6464 // |x| > 1.5 * ln2
6565 if (hx > 0x3F851592) {
6666 k = i32(invln2 * x + half[usize(sign)]);
67 }
68 else {
67 } else {
6968 k = 1 - sign - sign;
7069 }
7170
......@@ -79,8 +78,7 @@ fn exp32(x_: f32) f32 {
7978 k = 0;
8079 hi = x;
8180 lo = 0;
82 }
83 else {
81 } else {
8482 math.forceEval(0x1.0p127 + x); // inexact
8583 return 1 + x;
8684 }
......@@ -99,15 +97,15 @@ fn exp32(x_: f32) f32 {
9997fn exp64(x_: f64) f64 {
10098 @setFloatMode(this, builtin.FloatMode.Strict);
10199
102 const half = []const f64 { 0.5, -0.5 };
100 const half = []const f64{ 0.5, -0.5 };
103101 const ln2hi: f64 = 6.93147180369123816490e-01;
104102 const ln2lo: f64 = 1.90821492927058770002e-10;
105103 const invln2: f64 = 1.44269504088896338700e+00;
106 const P1: f64 = 1.66666666666666019037e-01;
107 const P2: f64 = -2.77777777770155933842e-03;
108 const P3: f64 = 6.61375632143793436117e-05;
109 const P4: f64 = -1.65339022054652515390e-06;
110 const P5: f64 = 4.13813679705723846039e-08;
104 const P1: f64 = 1.66666666666666019037e-01;
105 const P2: f64 = -2.77777777770155933842e-03;
106 const P3: f64 = 6.61375632143793436117e-05;
107 const P4: f64 = -1.65339022054652515390e-06;
108 const P5: f64 = 4.13813679705723846039e-08;
111109
112110 var x = x_;
113111 var ux = @bitCast(u64, x);
......@@ -151,8 +149,7 @@ fn exp64(x_: f64) f64 {
151149 // |x| >= 1.5 * ln2
152150 if (hx > 0x3FF0A2B2) {
153151 k = i32(invln2 * x + half[usize(sign)]);
154 }
155 else {
152 } else {
156153 k = 1 - sign - sign;
157154 }
158155
......@@ -166,8 +163,7 @@ fn exp64(x_: f64) f64 {
166163 k = 0;
167164 hi = x;
168165 lo = 0;
169 }
170 else {
166 } else {
171167 // inexact if x != 0
172168 // math.forceEval(0x1.0p1023 + x);
173169 return 1 + x;
std/math/exp2.zig+140-140
......@@ -16,7 +16,7 @@ pub fn exp2(x: var) @typeOf(x) {
1616 };
1717}
1818
19const exp2ft = []const f64 {
19const exp2ft = []const f64{
2020 0x1.6a09e667f3bcdp-1,
2121 0x1.7a11473eb0187p-1,
2222 0x1.8ace5422aa0dbp-1,
......@@ -92,195 +92,195 @@ fn exp2_32(x: f32) f32 {
9292 return f32(r * uk);
9393}
9494
95const exp2dt = []f64 {
95const exp2dt = []f64{
9696 // exp2(z + eps) eps
97 0x1.6a09e667f3d5dp-1, 0x1.9880p-44,
98 0x1.6b052fa751744p-1, 0x1.8000p-50,
97 0x1.6a09e667f3d5dp-1, 0x1.9880p-44,
98 0x1.6b052fa751744p-1, 0x1.8000p-50,
9999 0x1.6c012750bd9fep-1, -0x1.8780p-45,
100 0x1.6cfdcddd476bfp-1, 0x1.ec00p-46,
100 0x1.6cfdcddd476bfp-1, 0x1.ec00p-46,
101101 0x1.6dfb23c651a29p-1, -0x1.8000p-50,
102102 0x1.6ef9298593ae3p-1, -0x1.c000p-52,
103103 0x1.6ff7df9519386p-1, -0x1.fd80p-45,
104104 0x1.70f7466f42da3p-1, -0x1.c880p-45,
105 0x1.71f75e8ec5fc3p-1, 0x1.3c00p-46,
105 0x1.71f75e8ec5fc3p-1, 0x1.3c00p-46,
106106 0x1.72f8286eacf05p-1, -0x1.8300p-44,
107107 0x1.73f9a48a58152p-1, -0x1.0c00p-47,
108 0x1.74fbd35d7ccfcp-1, 0x1.f880p-45,
109 0x1.75feb564267f1p-1, 0x1.3e00p-47,
108 0x1.74fbd35d7ccfcp-1, 0x1.f880p-45,
109 0x1.75feb564267f1p-1, 0x1.3e00p-47,
110110 0x1.77024b1ab6d48p-1, -0x1.7d00p-45,
111111 0x1.780694fde5d38p-1, -0x1.d000p-50,
112 0x1.790b938ac1d00p-1, 0x1.3000p-49,
112 0x1.790b938ac1d00p-1, 0x1.3000p-49,
113113 0x1.7a11473eb0178p-1, -0x1.d000p-49,
114 0x1.7b17b0976d060p-1, 0x1.0400p-45,
115 0x1.7c1ed0130c133p-1, 0x1.0000p-53,
114 0x1.7b17b0976d060p-1, 0x1.0400p-45,
115 0x1.7c1ed0130c133p-1, 0x1.0000p-53,
116116 0x1.7d26a62ff8636p-1, -0x1.6900p-45,
117117 0x1.7e2f336cf4e3bp-1, -0x1.2e00p-47,
118118 0x1.7f3878491c3e8p-1, -0x1.4580p-45,
119 0x1.80427543e1b4ep-1, 0x1.3000p-44,
120 0x1.814d2add1071ap-1, 0x1.f000p-47,
119 0x1.80427543e1b4ep-1, 0x1.3000p-44,
120 0x1.814d2add1071ap-1, 0x1.f000p-47,
121121 0x1.82589994ccd7ep-1, -0x1.1c00p-45,
122 0x1.8364c1eb942d0p-1, 0x1.9d00p-45,
123 0x1.8471a4623cab5p-1, 0x1.7100p-43,
124 0x1.857f4179f5bbcp-1, 0x1.2600p-45,
122 0x1.8364c1eb942d0p-1, 0x1.9d00p-45,
123 0x1.8471a4623cab5p-1, 0x1.7100p-43,
124 0x1.857f4179f5bbcp-1, 0x1.2600p-45,
125125 0x1.868d99b4491afp-1, -0x1.2c40p-44,
126126 0x1.879cad931a395p-1, -0x1.3000p-45,
127127 0x1.88ac7d98a65b8p-1, -0x1.a800p-45,
128128 0x1.89bd0a4785800p-1, -0x1.d000p-49,
129 0x1.8ace5422aa223p-1, 0x1.3280p-44,
130 0x1.8be05bad619fap-1, 0x1.2b40p-43,
129 0x1.8ace5422aa223p-1, 0x1.3280p-44,
130 0x1.8be05bad619fap-1, 0x1.2b40p-43,
131131 0x1.8cf3216b54383p-1, -0x1.ed00p-45,
132132 0x1.8e06a5e08664cp-1, -0x1.0500p-45,
133 0x1.8f1ae99157807p-1, 0x1.8280p-45,
133 0x1.8f1ae99157807p-1, 0x1.8280p-45,
134134 0x1.902fed0282c0ep-1, -0x1.cb00p-46,
135135 0x1.9145b0b91ff96p-1, -0x1.5e00p-47,
136 0x1.925c353aa2ff9p-1, 0x1.5400p-48,
137 0x1.93737b0cdc64ap-1, 0x1.7200p-46,
136 0x1.925c353aa2ff9p-1, 0x1.5400p-48,
137 0x1.93737b0cdc64ap-1, 0x1.7200p-46,
138138 0x1.948b82b5f98aep-1, -0x1.9000p-47,
139 0x1.95a44cbc852cbp-1, 0x1.5680p-45,
139 0x1.95a44cbc852cbp-1, 0x1.5680p-45,
140140 0x1.96bdd9a766f21p-1, -0x1.6d00p-44,
141141 0x1.97d829fde4e2ap-1, -0x1.1000p-47,
142 0x1.98f33e47a23a3p-1, 0x1.d000p-45,
142 0x1.98f33e47a23a3p-1, 0x1.d000p-45,
143143 0x1.9a0f170ca0604p-1, -0x1.8a40p-44,
144 0x1.9b2bb4d53ff89p-1, 0x1.55c0p-44,
145 0x1.9c49182a3f15bp-1, 0x1.6b80p-45,
144 0x1.9b2bb4d53ff89p-1, 0x1.55c0p-44,
145 0x1.9c49182a3f15bp-1, 0x1.6b80p-45,
146146 0x1.9d674194bb8c5p-1, -0x1.c000p-49,
147 0x1.9e86319e3238ep-1, 0x1.7d00p-46,
148 0x1.9fa5e8d07f302p-1, 0x1.6400p-46,
147 0x1.9e86319e3238ep-1, 0x1.7d00p-46,
148 0x1.9fa5e8d07f302p-1, 0x1.6400p-46,
149149 0x1.a0c667b5de54dp-1, -0x1.5000p-48,
150 0x1.a1e7aed8eb8f6p-1, 0x1.9e00p-47,
151 0x1.a309bec4a2e27p-1, 0x1.ad80p-45,
150 0x1.a1e7aed8eb8f6p-1, 0x1.9e00p-47,
151 0x1.a309bec4a2e27p-1, 0x1.ad80p-45,
152152 0x1.a42c980460a5dp-1, -0x1.af00p-46,
153 0x1.a5503b23e259bp-1, 0x1.b600p-47,
154 0x1.a674a8af46213p-1, 0x1.8880p-44,
155 0x1.a799e1330b3a7p-1, 0x1.1200p-46,
156 0x1.a8bfe53c12e8dp-1, 0x1.6c00p-47,
153 0x1.a5503b23e259bp-1, 0x1.b600p-47,
154 0x1.a674a8af46213p-1, 0x1.8880p-44,
155 0x1.a799e1330b3a7p-1, 0x1.1200p-46,
156 0x1.a8bfe53c12e8dp-1, 0x1.6c00p-47,
157157 0x1.a9e6b5579fcd2p-1, -0x1.9b80p-45,
158 0x1.ab0e521356fb8p-1, 0x1.b700p-45,
159 0x1.ac36bbfd3f381p-1, 0x1.9000p-50,
160 0x1.ad5ff3a3c2780p-1, 0x1.4000p-49,
158 0x1.ab0e521356fb8p-1, 0x1.b700p-45,
159 0x1.ac36bbfd3f381p-1, 0x1.9000p-50,
160 0x1.ad5ff3a3c2780p-1, 0x1.4000p-49,
161161 0x1.ae89f995ad2a3p-1, -0x1.c900p-45,
162 0x1.afb4ce622f367p-1, 0x1.6500p-46,
163 0x1.b0e07298db790p-1, 0x1.fd40p-45,
164 0x1.b20ce6c9a89a9p-1, 0x1.2700p-46,
165 0x1.b33a2b84f1a4bp-1, 0x1.d470p-43,
162 0x1.afb4ce622f367p-1, 0x1.6500p-46,
163 0x1.b0e07298db790p-1, 0x1.fd40p-45,
164 0x1.b20ce6c9a89a9p-1, 0x1.2700p-46,
165 0x1.b33a2b84f1a4bp-1, 0x1.d470p-43,
166166 0x1.b468415b747e7p-1, -0x1.8380p-44,
167 0x1.b59728de5593ap-1, 0x1.8000p-54,
168 0x1.b6c6e29f1c56ap-1, 0x1.ad00p-47,
169 0x1.b7f76f2fb5e50p-1, 0x1.e800p-50,
167 0x1.b59728de5593ap-1, 0x1.8000p-54,
168 0x1.b6c6e29f1c56ap-1, 0x1.ad00p-47,
169 0x1.b7f76f2fb5e50p-1, 0x1.e800p-50,
170170 0x1.b928cf22749b2p-1, -0x1.4c00p-47,
171171 0x1.ba5b030a10603p-1, -0x1.d700p-47,
172 0x1.bb8e0b79a6f66p-1, 0x1.d900p-47,
173 0x1.bcc1e904bc1ffp-1, 0x1.2a00p-47,
172 0x1.bb8e0b79a6f66p-1, 0x1.d900p-47,
173 0x1.bcc1e904bc1ffp-1, 0x1.2a00p-47,
174174 0x1.bdf69c3f3a16fp-1, -0x1.f780p-46,
175175 0x1.bf2c25bd71db8p-1, -0x1.0a00p-46,
176176 0x1.c06286141b2e9p-1, -0x1.1400p-46,
177 0x1.c199bdd8552e0p-1, 0x1.be00p-47,
177 0x1.c199bdd8552e0p-1, 0x1.be00p-47,
178178 0x1.c2d1cd9fa64eep-1, -0x1.9400p-47,
179179 0x1.c40ab5fffd02fp-1, -0x1.ed00p-47,
180 0x1.c544778fafd15p-1, 0x1.9660p-44,
180 0x1.c544778fafd15p-1, 0x1.9660p-44,
181181 0x1.c67f12e57d0cbp-1, -0x1.a100p-46,
182182 0x1.c7ba88988c1b6p-1, -0x1.8458p-42,
183183 0x1.c8f6d9406e733p-1, -0x1.a480p-46,
184 0x1.ca3405751c4dfp-1, 0x1.b000p-51,
185 0x1.cb720dcef9094p-1, 0x1.1400p-47,
186 0x1.ccb0f2e6d1689p-1, 0x1.0200p-48,
187 0x1.cdf0b555dc412p-1, 0x1.3600p-48,
184 0x1.ca3405751c4dfp-1, 0x1.b000p-51,
185 0x1.cb720dcef9094p-1, 0x1.1400p-47,
186 0x1.ccb0f2e6d1689p-1, 0x1.0200p-48,
187 0x1.cdf0b555dc412p-1, 0x1.3600p-48,
188188 0x1.cf3155b5bab3bp-1, -0x1.6900p-47,
189 0x1.d072d4a0789bcp-1, 0x1.9a00p-47,
189 0x1.d072d4a0789bcp-1, 0x1.9a00p-47,
190190 0x1.d1b532b08c8fap-1, -0x1.5e00p-46,
191 0x1.d2f87080d8a85p-1, 0x1.d280p-46,
192 0x1.d43c8eacaa203p-1, 0x1.1a00p-47,
193 0x1.d5818dcfba491p-1, 0x1.f000p-50,
191 0x1.d2f87080d8a85p-1, 0x1.d280p-46,
192 0x1.d43c8eacaa203p-1, 0x1.1a00p-47,
193 0x1.d5818dcfba491p-1, 0x1.f000p-50,
194194 0x1.d6c76e862e6a1p-1, -0x1.3a00p-47,
195195 0x1.d80e316c9834ep-1, -0x1.cd80p-47,
196 0x1.d955d71ff6090p-1, 0x1.4c00p-48,
197 0x1.da9e603db32aep-1, 0x1.f900p-48,
198 0x1.dbe7cd63a8325p-1, 0x1.9800p-49,
196 0x1.d955d71ff6090p-1, 0x1.4c00p-48,
197 0x1.da9e603db32aep-1, 0x1.f900p-48,
198 0x1.dbe7cd63a8325p-1, 0x1.9800p-49,
199199 0x1.dd321f301b445p-1, -0x1.5200p-48,
200200 0x1.de7d5641c05bfp-1, -0x1.d700p-46,
201201 0x1.dfc97337b9aecp-1, -0x1.6140p-46,
202 0x1.e11676b197d5ep-1, 0x1.b480p-47,
203 0x1.e264614f5a3e7p-1, 0x1.0ce0p-43,
204 0x1.e3b333b16ee5cp-1, 0x1.c680p-47,
202 0x1.e11676b197d5ep-1, 0x1.b480p-47,
203 0x1.e264614f5a3e7p-1, 0x1.0ce0p-43,
204 0x1.e3b333b16ee5cp-1, 0x1.c680p-47,
205205 0x1.e502ee78b3fb4p-1, -0x1.9300p-47,
206206 0x1.e653924676d68p-1, -0x1.5000p-49,
207207 0x1.e7a51fbc74c44p-1, -0x1.7f80p-47,
208208 0x1.e8f7977cdb726p-1, -0x1.3700p-48,
209 0x1.ea4afa2a490e8p-1, 0x1.5d00p-49,
210 0x1.eb9f4867ccae4p-1, 0x1.61a0p-46,
211 0x1.ecf482d8e680dp-1, 0x1.5500p-48,
212 0x1.ee4aaa2188514p-1, 0x1.6400p-51,
209 0x1.ea4afa2a490e8p-1, 0x1.5d00p-49,
210 0x1.eb9f4867ccae4p-1, 0x1.61a0p-46,
211 0x1.ecf482d8e680dp-1, 0x1.5500p-48,
212 0x1.ee4aaa2188514p-1, 0x1.6400p-51,
213213 0x1.efa1bee615a13p-1, -0x1.e800p-49,
214214 0x1.f0f9c1cb64106p-1, -0x1.a880p-48,
215215 0x1.f252b376bb963p-1, -0x1.c900p-45,
216 0x1.f3ac948dd7275p-1, 0x1.a000p-53,
216 0x1.f3ac948dd7275p-1, 0x1.a000p-53,
217217 0x1.f50765b6e4524p-1, -0x1.4f00p-48,
218 0x1.f6632798844fdp-1, 0x1.a800p-51,
219 0x1.f7bfdad9cbe38p-1, 0x1.abc0p-48,
218 0x1.f6632798844fdp-1, 0x1.a800p-51,
219 0x1.f7bfdad9cbe38p-1, 0x1.abc0p-48,
220220 0x1.f91d802243c82p-1, -0x1.4600p-50,
221221 0x1.fa7c1819e908ep-1, -0x1.b0c0p-47,
222222 0x1.fbdba3692d511p-1, -0x1.0e00p-51,
223223 0x1.fd3c22b8f7194p-1, -0x1.0de8p-46,
224 0x1.fe9d96b2a23eep-1, 0x1.e430p-49,
225 0x1.0000000000000p+0, 0x0.0000p+0,
224 0x1.fe9d96b2a23eep-1, 0x1.e430p-49,
225 0x1.0000000000000p+0, 0x0.0000p+0,
226226 0x1.00b1afa5abcbep+0, -0x1.3400p-52,
227227 0x1.0163da9fb3303p+0, -0x1.2170p-46,
228 0x1.02168143b0282p+0, 0x1.a400p-52,
229 0x1.02c9a3e77806cp+0, 0x1.f980p-49,
228 0x1.02168143b0282p+0, 0x1.a400p-52,
229 0x1.02c9a3e77806cp+0, 0x1.f980p-49,
230230 0x1.037d42e11bbcap+0, -0x1.7400p-51,
231 0x1.04315e86e7f89p+0, 0x1.8300p-50,
231 0x1.04315e86e7f89p+0, 0x1.8300p-50,
232232 0x1.04e5f72f65467p+0, -0x1.a3f0p-46,
233233 0x1.059b0d315855ap+0, -0x1.2840p-47,
234 0x1.0650a0e3c1f95p+0, 0x1.1600p-48,
235 0x1.0706b29ddf71ap+0, 0x1.5240p-46,
234 0x1.0650a0e3c1f95p+0, 0x1.1600p-48,
235 0x1.0706b29ddf71ap+0, 0x1.5240p-46,
236236 0x1.07bd42b72a82dp+0, -0x1.9a00p-49,
237 0x1.0874518759bd0p+0, 0x1.6400p-49,
237 0x1.0874518759bd0p+0, 0x1.6400p-49,
238238 0x1.092bdf66607c8p+0, -0x1.0780p-47,
239239 0x1.09e3ecac6f383p+0, -0x1.8000p-54,
240 0x1.0a9c79b1f3930p+0, 0x1.fa00p-48,
240 0x1.0a9c79b1f3930p+0, 0x1.fa00p-48,
241241 0x1.0b5586cf988fcp+0, -0x1.ac80p-48,
242 0x1.0c0f145e46c8ap+0, 0x1.9c00p-50,
243 0x1.0cc922b724816p+0, 0x1.5200p-47,
242 0x1.0c0f145e46c8ap+0, 0x1.9c00p-50,
243 0x1.0cc922b724816p+0, 0x1.5200p-47,
244244 0x1.0d83b23395dd8p+0, -0x1.ad00p-48,
245 0x1.0e3ec32d3d1f3p+0, 0x1.bac0p-46,
245 0x1.0e3ec32d3d1f3p+0, 0x1.bac0p-46,
246246 0x1.0efa55fdfa9a6p+0, -0x1.4e80p-47,
247247 0x1.0fb66affed2f0p+0, -0x1.d300p-47,
248 0x1.1073028d7234bp+0, 0x1.1500p-48,
249 0x1.11301d0125b5bp+0, 0x1.c000p-49,
250 0x1.11edbab5e2af9p+0, 0x1.6bc0p-46,
251 0x1.12abdc06c31d5p+0, 0x1.8400p-49,
248 0x1.1073028d7234bp+0, 0x1.1500p-48,
249 0x1.11301d0125b5bp+0, 0x1.c000p-49,
250 0x1.11edbab5e2af9p+0, 0x1.6bc0p-46,
251 0x1.12abdc06c31d5p+0, 0x1.8400p-49,
252252 0x1.136a814f2047dp+0, -0x1.ed00p-47,
253 0x1.1429aaea92de9p+0, 0x1.8e00p-49,
254 0x1.14e95934f3138p+0, 0x1.b400p-49,
255 0x1.15a98c8a58e71p+0, 0x1.5300p-47,
256 0x1.166a45471c3dfp+0, 0x1.3380p-47,
257 0x1.172b83c7d5211p+0, 0x1.8d40p-45,
253 0x1.1429aaea92de9p+0, 0x1.8e00p-49,
254 0x1.14e95934f3138p+0, 0x1.b400p-49,
255 0x1.15a98c8a58e71p+0, 0x1.5300p-47,
256 0x1.166a45471c3dfp+0, 0x1.3380p-47,
257 0x1.172b83c7d5211p+0, 0x1.8d40p-45,
258258 0x1.17ed48695bb9fp+0, -0x1.5d00p-47,
259259 0x1.18af9388c8d93p+0, -0x1.c880p-46,
260 0x1.1972658375d66p+0, 0x1.1f00p-46,
261 0x1.1a35beb6fcba7p+0, 0x1.0480p-46,
260 0x1.1972658375d66p+0, 0x1.1f00p-46,
261 0x1.1a35beb6fcba7p+0, 0x1.0480p-46,
262262 0x1.1af99f81387e3p+0, -0x1.7390p-43,
263 0x1.1bbe084045d54p+0, 0x1.4e40p-45,
263 0x1.1bbe084045d54p+0, 0x1.4e40p-45,
264264 0x1.1c82f95281c43p+0, -0x1.a200p-47,
265 0x1.1d4873168b9b2p+0, 0x1.3800p-49,
266 0x1.1e0e75eb44031p+0, 0x1.ac00p-49,
267 0x1.1ed5022fcd938p+0, 0x1.1900p-47,
265 0x1.1d4873168b9b2p+0, 0x1.3800p-49,
266 0x1.1e0e75eb44031p+0, 0x1.ac00p-49,
267 0x1.1ed5022fcd938p+0, 0x1.1900p-47,
268268 0x1.1f9c18438cdf7p+0, -0x1.b780p-46,
269 0x1.2063b88628d8fp+0, 0x1.d940p-45,
270 0x1.212be3578a81ep+0, 0x1.8000p-50,
271 0x1.21f49917ddd41p+0, 0x1.b340p-45,
272 0x1.22bdda2791323p+0, 0x1.9f80p-46,
269 0x1.2063b88628d8fp+0, 0x1.d940p-45,
270 0x1.212be3578a81ep+0, 0x1.8000p-50,
271 0x1.21f49917ddd41p+0, 0x1.b340p-45,
272 0x1.22bdda2791323p+0, 0x1.9f80p-46,
273273 0x1.2387a6e7561e7p+0, -0x1.9c80p-46,
274 0x1.2451ffb821427p+0, 0x1.2300p-47,
274 0x1.2451ffb821427p+0, 0x1.2300p-47,
275275 0x1.251ce4fb2a602p+0, -0x1.3480p-46,
276 0x1.25e85711eceb0p+0, 0x1.2700p-46,
277 0x1.26b4565e27d16p+0, 0x1.1d00p-46,
278 0x1.2780e341de00fp+0, 0x1.1ee0p-44,
276 0x1.25e85711eceb0p+0, 0x1.2700p-46,
277 0x1.26b4565e27d16p+0, 0x1.1d00p-46,
278 0x1.2780e341de00fp+0, 0x1.1ee0p-44,
279279 0x1.284dfe1f5633ep+0, -0x1.4c00p-46,
280280 0x1.291ba7591bb30p+0, -0x1.3d80p-46,
281 0x1.29e9df51fdf09p+0, 0x1.8b00p-47,
281 0x1.29e9df51fdf09p+0, 0x1.8b00p-47,
282282 0x1.2ab8a66d10e9bp+0, -0x1.27c0p-45,
283 0x1.2b87fd0dada3ap+0, 0x1.a340p-45,
283 0x1.2b87fd0dada3ap+0, 0x1.a340p-45,
284284 0x1.2c57e39771af9p+0, -0x1.0800p-46,
285285 0x1.2d285a6e402d9p+0, -0x1.ed00p-47,
286286 0x1.2df961f641579p+0, -0x1.4200p-48,
......@@ -290,78 +290,78 @@ const exp2dt = []f64 {
290290 0x1.31432edeea50bp+0, -0x1.0df8p-40,
291291 0x1.32170fc4cd7b8p+0, -0x1.2480p-45,
292292 0x1.32eb83ba8e9a2p+0, -0x1.5980p-45,
293 0x1.33c08b2641766p+0, 0x1.ed00p-46,
293 0x1.33c08b2641766p+0, 0x1.ed00p-46,
294294 0x1.3496266e3fa27p+0, -0x1.c000p-50,
295295 0x1.356c55f929f0fp+0, -0x1.0d80p-44,
296 0x1.36431a2de88b9p+0, 0x1.2c80p-45,
297 0x1.371a7373aaa39p+0, 0x1.0600p-45,
296 0x1.36431a2de88b9p+0, 0x1.2c80p-45,
297 0x1.371a7373aaa39p+0, 0x1.0600p-45,
298298 0x1.37f26231e74fep+0, -0x1.6600p-46,
299299 0x1.38cae6d05d838p+0, -0x1.ae00p-47,
300300 0x1.39a401b713ec3p+0, -0x1.4720p-43,
301 0x1.3a7db34e5a020p+0, 0x1.8200p-47,
302 0x1.3b57fbfec6e95p+0, 0x1.e800p-44,
303 0x1.3c32dc313a8f2p+0, 0x1.f800p-49,
301 0x1.3a7db34e5a020p+0, 0x1.8200p-47,
302 0x1.3b57fbfec6e95p+0, 0x1.e800p-44,
303 0x1.3c32dc313a8f2p+0, 0x1.f800p-49,
304304 0x1.3d0e544ede122p+0, -0x1.7a00p-46,
305 0x1.3dea64c1234bbp+0, 0x1.6300p-45,
305 0x1.3dea64c1234bbp+0, 0x1.6300p-45,
306306 0x1.3ec70df1c4eccp+0, -0x1.8a60p-43,
307307 0x1.3fa4504ac7e8cp+0, -0x1.cdc0p-44,
308 0x1.40822c367a0bbp+0, 0x1.5b80p-45,
309 0x1.4160a21f72e95p+0, 0x1.ec00p-46,
308 0x1.40822c367a0bbp+0, 0x1.5b80p-45,
309 0x1.4160a21f72e95p+0, 0x1.ec00p-46,
310310 0x1.423fb27094646p+0, -0x1.3600p-46,
311 0x1.431f5d950a920p+0, 0x1.3980p-45,
312 0x1.43ffa3f84b9ebp+0, 0x1.a000p-48,
311 0x1.431f5d950a920p+0, 0x1.3980p-45,
312 0x1.43ffa3f84b9ebp+0, 0x1.a000p-48,
313313 0x1.44e0860618919p+0, -0x1.6c00p-48,
314314 0x1.45c2042a7d201p+0, -0x1.bc00p-47,
315315 0x1.46a41ed1d0016p+0, -0x1.2800p-46,
316 0x1.4786d668b3326p+0, 0x1.0e00p-44,
316 0x1.4786d668b3326p+0, 0x1.0e00p-44,
317317 0x1.486a2b5c13c00p+0, -0x1.d400p-45,
318 0x1.494e1e192af04p+0, 0x1.c200p-47,
318 0x1.494e1e192af04p+0, 0x1.c200p-47,
319319 0x1.4a32af0d7d372p+0, -0x1.e500p-46,
320 0x1.4b17dea6db801p+0, 0x1.7800p-47,
320 0x1.4b17dea6db801p+0, 0x1.7800p-47,
321321 0x1.4bfdad53629e1p+0, -0x1.3800p-46,
322 0x1.4ce41b817c132p+0, 0x1.0800p-47,
323 0x1.4dcb299fddddbp+0, 0x1.c700p-45,
322 0x1.4ce41b817c132p+0, 0x1.0800p-47,
323 0x1.4dcb299fddddbp+0, 0x1.c700p-45,
324324 0x1.4eb2d81d8ab96p+0, -0x1.ce00p-46,
325 0x1.4f9b2769d2d02p+0, 0x1.9200p-46,
325 0x1.4f9b2769d2d02p+0, 0x1.9200p-46,
326326 0x1.508417f4531c1p+0, -0x1.8c00p-47,
327327 0x1.516daa2cf662ap+0, -0x1.a000p-48,
328 0x1.5257de83f51eap+0, 0x1.a080p-43,
328 0x1.5257de83f51eap+0, 0x1.a080p-43,
329329 0x1.5342b569d4edap+0, -0x1.6d80p-45,
330330 0x1.542e2f4f6ac1ap+0, -0x1.2440p-44,
331 0x1.551a4ca5d94dbp+0, 0x1.83c0p-43,
332 0x1.56070dde9116bp+0, 0x1.4b00p-45,
333 0x1.56f4736b529dep+0, 0x1.15a0p-43,
331 0x1.551a4ca5d94dbp+0, 0x1.83c0p-43,
332 0x1.56070dde9116bp+0, 0x1.4b00p-45,
333 0x1.56f4736b529dep+0, 0x1.15a0p-43,
334334 0x1.57e27dbe2c40ep+0, -0x1.9e00p-45,
335335 0x1.58d12d497c76fp+0, -0x1.3080p-45,
336 0x1.59c0827ff0b4cp+0, 0x1.dec0p-43,
336 0x1.59c0827ff0b4cp+0, 0x1.dec0p-43,
337337 0x1.5ab07dd485427p+0, -0x1.4000p-51,
338 0x1.5ba11fba87af4p+0, 0x1.0080p-44,
338 0x1.5ba11fba87af4p+0, 0x1.0080p-44,
339339 0x1.5c9268a59460bp+0, -0x1.6c80p-45,
340 0x1.5d84590998e3fp+0, 0x1.69a0p-43,
340 0x1.5d84590998e3fp+0, 0x1.69a0p-43,
341341 0x1.5e76f15ad20e1p+0, -0x1.b400p-46,
342 0x1.5f6a320dcebcap+0, 0x1.7700p-46,
343 0x1.605e1b976dcb8p+0, 0x1.6f80p-45,
344 0x1.6152ae6cdf715p+0, 0x1.1000p-47,
342 0x1.5f6a320dcebcap+0, 0x1.7700p-46,
343 0x1.605e1b976dcb8p+0, 0x1.6f80p-45,
344 0x1.6152ae6cdf715p+0, 0x1.1000p-47,
345345 0x1.6247eb03a5531p+0, -0x1.5d00p-46,
346346 0x1.633dd1d1929b5p+0, -0x1.2d00p-46,
347347 0x1.6434634ccc313p+0, -0x1.a800p-49,
348348 0x1.652b9febc8efap+0, -0x1.8600p-45,
349 0x1.6623882553397p+0, 0x1.1fe0p-40,
349 0x1.6623882553397p+0, 0x1.1fe0p-40,
350350 0x1.671c1c708328ep+0, -0x1.7200p-44,
351 0x1.68155d44ca97ep+0, 0x1.6800p-49,
351 0x1.68155d44ca97ep+0, 0x1.6800p-49,
352352 0x1.690f4b19e9471p+0, -0x1.9780p-45,
353353};
354354
355355fn exp2_64(x: f64) f64 {
356356 @setFloatMode(this, @import("builtin").FloatMode.Strict);
357357
358 const tblsiz = u32(exp2dt.len / 2);
358 const tblsiz = u32(exp2dt.len / 2);
359359 const redux: f64 = 0x1.8p52 / f64(tblsiz);
360 const P1: f64 = 0x1.62e42fefa39efp-1;
361 const P2: f64 = 0x1.ebfbdff82c575p-3;
362 const P3: f64 = 0x1.c6b08d704a0a6p-5;
363 const P4: f64 = 0x1.3b2ab88f70400p-7;
364 const P5: f64 = 0x1.5d88003875c74p-10;
360 const P1: f64 = 0x1.62e42fefa39efp-1;
361 const P2: f64 = 0x1.ebfbdff82c575p-3;
362 const P3: f64 = 0x1.c6b08d704a0a6p-5;
363 const P4: f64 = 0x1.3b2ab88f70400p-7;
364 const P5: f64 = 0x1.5d88003875c74p-10;
365365
366366 const ux = @bitCast(u64, x);
367367 const ix = u32(ux >> 32) & 0x7FFFFFFF;
std/math/expm1.zig+11-13
......@@ -21,11 +21,11 @@ pub fn expm1(x: var) @typeOf(x) {
2121fn expm1_32(x_: f32) f32 {
2222 @setFloatMode(this, builtin.FloatMode.Strict);
2323 const o_threshold: f32 = 8.8721679688e+01;
24 const ln2_hi: f32 = 6.9313812256e-01;
25 const ln2_lo: f32 = 9.0580006145e-06;
26 const invln2: f32 = 1.4426950216e+00;
24 const ln2_hi: f32 = 6.9313812256e-01;
25 const ln2_lo: f32 = 9.0580006145e-06;
26 const invln2: f32 = 1.4426950216e+00;
2727 const Q1: f32 = -3.3333212137e-2;
28 const Q2: f32 = 1.5807170421e-3;
28 const Q2: f32 = 1.5807170421e-3;
2929
3030 var x = x_;
3131 const ux = @bitCast(u32, x);
......@@ -93,8 +93,7 @@ fn expm1_32(x_: f32) f32 {
9393 math.forceEval(x * x);
9494 }
9595 return x;
96 }
97 else {
96 } else {
9897 k = 0;
9998 }
10099
......@@ -148,13 +147,13 @@ fn expm1_32(x_: f32) f32 {
148147fn expm1_64(x_: f64) f64 {
149148 @setFloatMode(this, builtin.FloatMode.Strict);
150149 const o_threshold: f64 = 7.09782712893383973096e+02;
151 const ln2_hi: f64 = 6.93147180369123816490e-01;
152 const ln2_lo: f64 = 1.90821492927058770002e-10;
153 const invln2: f64 = 1.44269504088896338700e+00;
150 const ln2_hi: f64 = 6.93147180369123816490e-01;
151 const ln2_lo: f64 = 1.90821492927058770002e-10;
152 const invln2: f64 = 1.44269504088896338700e+00;
154153 const Q1: f64 = -3.33333333333331316428e-02;
155 const Q2: f64 = 1.58730158725481460165e-03;
154 const Q2: f64 = 1.58730158725481460165e-03;
156155 const Q3: f64 = -7.93650757867487942473e-05;
157 const Q4: f64 = 4.00821782732936239552e-06;
156 const Q4: f64 = 4.00821782732936239552e-06;
158157 const Q5: f64 = -2.01099218183624371326e-07;
159158
160159 var x = x_;
......@@ -223,8 +222,7 @@ fn expm1_64(x_: f64) f64 {
223222 math.forceEval(f32(x));
224223 }
225224 return x;
226 }
227 else {
225 } else {
228226 k = 0;
229227 }
230228
std/math/index.zig+1-1
......@@ -501,7 +501,7 @@ test "math.negateCast" {
501501 if (negateCast(u32(@maxValue(i32) + 10))) |_| unreachable else |err| assert(err == error.Overflow);
502502}
503503
504/// Cast an integer to a different integer type. If the value doesn't fit,
504/// Cast an integer to a different integer type. If the value doesn't fit,
505505/// return an error.
506506pub fn cast(comptime T: type, x: var) (error{Overflow}!T) {
507507 comptime assert(@typeId(T) == builtin.TypeId.Int); // must pass an integer
std/math/log1p.zig+1-2
......@@ -138,8 +138,7 @@ fn log1p_64(x: f64) f64 {
138138 c = 0;
139139 f = x;
140140 }
141 }
142 else if (hx >= 0x7FF00000) {
141 } else if (hx >= 0x7FF00000) {
143142 return x;
144143 }
145144
std/math/pow.zig-1
......@@ -28,7 +28,6 @@ const assert = std.debug.assert;
2828
2929// This implementation is taken from the go stlib, musl is a bit more complex.
3030pub fn pow(comptime T: type, x: T, y: T) T {
31
3231 @setFloatMode(this, @import("builtin").FloatMode.Strict);
3332
3433 if (T != f32 and T != f64) {
std/net.zig+19-13
......@@ -19,24 +19,30 @@ pub const Address = struct {
1919 os_addr: OsAddress,
2020
2121 pub fn initIp4(ip4: u32, port: u16) Address {
22 return Address{ .os_addr = posix.sockaddr{ .in = posix.sockaddr_in{
23 .family = posix.AF_INET,
24 .port = std.mem.endianSwapIfLe(u16, port),
25 .addr = ip4,
26 .zero = []u8{0} ** 8,
27 } } };
22 return Address{
23 .os_addr = posix.sockaddr{
24 .in = posix.sockaddr_in{
25 .family = posix.AF_INET,
26 .port = std.mem.endianSwapIfLe(u16, port),
27 .addr = ip4,
28 .zero = []u8{0} ** 8,
29 },
30 },
31 };
2832 }
2933
3034 pub fn initIp6(ip6: &const Ip6Addr, port: u16) Address {
3135 return Address{
3236 .family = posix.AF_INET6,
33 .os_addr = posix.sockaddr{ .in6 = posix.sockaddr_in6{
34 .family = posix.AF_INET6,
35 .port = std.mem.endianSwapIfLe(u16, port),
36 .flowinfo = 0,
37 .addr = ip6.addr,
38 .scope_id = ip6.scope_id,
39 } },
37 .os_addr = posix.sockaddr{
38 .in6 = posix.sockaddr_in6{
39 .family = posix.AF_INET6,
40 .port = std.mem.endianSwapIfLe(u16, port),
41 .flowinfo = 0,
42 .addr = ip6.addr,
43 .scope_id = ip6.scope_id,
44 },
45 },
4046 };
4147 }
4248
std/os/child_process.zig+3-8
......@@ -387,15 +387,12 @@ pub const ChildProcess = struct {
387387 const pid_err = posix.getErrno(pid_result);
388388 if (pid_err > 0) {
389389 return switch (pid_err) {
390 posix.EAGAIN,
391 posix.ENOMEM,
392 posix.ENOSYS => error.SystemResources,
390 posix.EAGAIN, posix.ENOMEM, posix.ENOSYS => error.SystemResources,
393391 else => os.unexpectedErrorPosix(pid_err),
394392 };
395393 }
396394 if (pid_result == 0) {
397395 // we are the child
398
399396 setUpChildIo(self.stdin_behavior, stdin_pipe[0], posix.STDIN_FILENO, dev_null_fd) catch |err| forkChildErrReport(err_pipe[1], err);
400397 setUpChildIo(self.stdout_behavior, stdout_pipe[1], posix.STDOUT_FILENO, dev_null_fd) catch |err| forkChildErrReport(err_pipe[1], err);
401398 setUpChildIo(self.stderr_behavior, stderr_pipe[1], posix.STDERR_FILENO, dev_null_fd) catch |err| forkChildErrReport(err_pipe[1], err);
......@@ -646,8 +643,7 @@ fn windowsCreateProcess(app_name: &u8, cmd_line: &u8, envp_ptr: ?&u8, cwd_ptr: ?
646643 if (windows.CreateProcessA(app_name, cmd_line, null, null, windows.TRUE, 0, @ptrCast(?&c_void, envp_ptr), cwd_ptr, lpStartupInfo, lpProcessInformation) == 0) {
647644 const err = windows.GetLastError();
648645 return switch (err) {
649 windows.ERROR.FILE_NOT_FOUND,
650 windows.ERROR.PATH_NOT_FOUND => error.FileNotFound,
646 windows.ERROR.FILE_NOT_FOUND, windows.ERROR.PATH_NOT_FOUND => error.FileNotFound,
651647 windows.ERROR.INVALID_PARAMETER => unreachable,
652648 windows.ERROR.INVALID_NAME => error.InvalidName,
653649 else => os.unexpectedErrorWindows(err),
......@@ -745,8 +741,7 @@ fn makePipe() ![2]i32 {
745741 const err = posix.getErrno(posix.pipe(&fds));
746742 if (err > 0) {
747743 return switch (err) {
748 posix.EMFILE,
749 posix.ENFILE => error.SystemResources,
744 posix.EMFILE, posix.ENFILE => error.SystemResources,
750745 else => os.unexpectedErrorPosix(err),
751746 };
752747 }
std/os/darwin.zig+66
......@@ -12,52 +12,71 @@ pub const STDERR_FILENO = 2;
1212
1313/// [MC2] no permissions
1414pub const PROT_NONE = 0x00;
15
1516/// [MC2] pages can be read
1617pub const PROT_READ = 0x01;
18
1719/// [MC2] pages can be written
1820pub const PROT_WRITE = 0x02;
21
1922/// [MC2] pages can be executed
2023pub const PROT_EXEC = 0x04;
2124
2225/// allocated from memory, swap space
2326pub const MAP_ANONYMOUS = 0x1000;
27
2428/// map from file (default)
2529pub const MAP_FILE = 0x0000;
30
2631/// interpret addr exactly
2732pub const MAP_FIXED = 0x0010;
33
2834/// region may contain semaphores
2935pub const MAP_HASSEMAPHORE = 0x0200;
36
3037/// changes are private
3138pub const MAP_PRIVATE = 0x0002;
39
3240/// share changes
3341pub const MAP_SHARED = 0x0001;
42
3443/// don't cache pages for this mapping
3544pub const MAP_NOCACHE = 0x0400;
45
3646/// don't reserve needed swap area
3747pub const MAP_NORESERVE = 0x0040;
3848pub const MAP_FAILED = @maxValue(usize);
3949
4050/// [XSI] no hang in wait/no child to reap
4151pub const WNOHANG = 0x00000001;
52
4253/// [XSI] notify on stop, untraced child
4354pub const WUNTRACED = 0x00000002;
4455
4556/// take signal on signal stack
4657pub const SA_ONSTACK = 0x0001;
58
4759/// restart system on signal return
4860pub const SA_RESTART = 0x0002;
61
4962/// reset to SIG_DFL when taking signal
5063pub const SA_RESETHAND = 0x0004;
64
5165/// do not generate SIGCHLD on child stop
5266pub const SA_NOCLDSTOP = 0x0008;
67
5368/// don't mask the signal we're delivering
5469pub const SA_NODEFER = 0x0010;
70
5571/// don't keep zombies around
5672pub const SA_NOCLDWAIT = 0x0020;
73
5774/// signal handler with SA_SIGINFO args
5875pub const SA_SIGINFO = 0x0040;
76
5977/// do not bounce off kernel's sigtramp
6078pub const SA_USERTRAMP = 0x0100;
79
6180/// signal handler with SA_SIGINFO args with 64bit regs information
6281pub const SA_64REGSET = 0x0200;
6382
......@@ -71,30 +90,43 @@ pub const R_OK = 4;
7190
7291/// open for reading only
7392pub const O_RDONLY = 0x0000;
93
7494/// open for writing only
7595pub const O_WRONLY = 0x0001;
96
7697/// open for reading and writing
7798pub const O_RDWR = 0x0002;
99
78100/// do not block on open or for data to become available
79101pub const O_NONBLOCK = 0x0004;
102
80103/// append on each write
81104pub const O_APPEND = 0x0008;
105
82106/// create file if it does not exist
83107pub const O_CREAT = 0x0200;
108
84109/// truncate size to 0
85110pub const O_TRUNC = 0x0400;
111
86112/// error if O_CREAT and the file exists
87113pub const O_EXCL = 0x0800;
114
88115/// atomically obtain a shared lock
89116pub const O_SHLOCK = 0x0010;
117
90118/// atomically obtain an exclusive lock
91119pub const O_EXLOCK = 0x0020;
120
92121/// do not follow symlinks
93122pub const O_NOFOLLOW = 0x0100;
123
94124/// allow open of symlinks
95125pub const O_SYMLINK = 0x200000;
126
96127/// descriptor requested for event notifications only
97128pub const O_EVTONLY = 0x8000;
129
98130/// mark as close-on-exec
99131pub const O_CLOEXEC = 0x1000000;
100132
......@@ -126,75 +158,109 @@ pub const DT_WHT = 14;
126158
127159/// block specified signal set
128160pub const SIG_BLOCK = 1;
161
129162/// unblock specified signal set
130163pub const SIG_UNBLOCK = 2;
164
131165/// set specified signal set
132166pub const SIG_SETMASK = 3;
133167
134168/// hangup
135169pub const SIGHUP = 1;
170
136171/// interrupt
137172pub const SIGINT = 2;
173
138174/// quit
139175pub const SIGQUIT = 3;
176
140177/// illegal instruction (not reset when caught)
141178pub const SIGILL = 4;
179
142180/// trace trap (not reset when caught)
143181pub const SIGTRAP = 5;
182
144183/// abort()
145184pub const SIGABRT = 6;
185
146186/// pollable event ([XSR] generated, not supported)
147187pub const SIGPOLL = 7;
188
148189/// compatibility
149190pub const SIGIOT = SIGABRT;
191
150192/// EMT instruction
151193pub const SIGEMT = 7;
194
152195/// floating point exception
153196pub const SIGFPE = 8;
197
154198/// kill (cannot be caught or ignored)
155199pub const SIGKILL = 9;
200
156201/// bus error
157202pub const SIGBUS = 10;
203
158204/// segmentation violation
159205pub const SIGSEGV = 11;
206
160207/// bad argument to system call
161208pub const SIGSYS = 12;
209
162210/// write on a pipe with no one to read it
163211pub const SIGPIPE = 13;
212
164213/// alarm clock
165214pub const SIGALRM = 14;
215
166216/// software termination signal from kill
167217pub const SIGTERM = 15;
218
168219/// urgent condition on IO channel
169220pub const SIGURG = 16;
221
170222/// sendable stop signal not from tty
171223pub const SIGSTOP = 17;
224
172225/// stop signal from tty
173226pub const SIGTSTP = 18;
227
174228/// continue a stopped process
175229pub const SIGCONT = 19;
230
176231/// to parent on child stop or exit
177232pub const SIGCHLD = 20;
233
178234/// to readers pgrp upon background tty read
179235pub const SIGTTIN = 21;
236
180237/// like TTIN for output if (tp->t_local&LTOSTOP)
181238pub const SIGTTOU = 22;
239
182240/// input/output possible signal
183241pub const SIGIO = 23;
242
184243/// exceeded CPU time limit
185244pub const SIGXCPU = 24;
245
186246/// exceeded file size limit
187247pub const SIGXFSZ = 25;
248
188249/// virtual time alarm
189250pub const SIGVTALRM = 26;
251
190252/// profiling time alarm
191253pub const SIGPROF = 27;
254
192255/// window size changes
193256pub const SIGWINCH = 28;
257
194258/// information request
195259pub const SIGINFO = 29;
260
196261/// user defined signal 1
197262pub const SIGUSR1 = 30;
263
198264/// user defined signal 2
199265pub const SIGUSR2 = 31;
200266
std/os/darwin_errno.zig+294-108
......@@ -1,142 +1,328 @@
1/// Operation not permitted
2pub const EPERM = 1;
13
2pub const EPERM = 1; /// Operation not permitted
3pub const ENOENT = 2; /// No such file or directory
4pub const ESRCH = 3; /// No such process
5pub const EINTR = 4; /// Interrupted system call
6pub const EIO = 5; /// Input/output error
7pub const ENXIO = 6; /// Device not configured
8pub const E2BIG = 7; /// Argument list too long
9pub const ENOEXEC = 8; /// Exec format error
10pub const EBADF = 9; /// Bad file descriptor
11pub const ECHILD = 10; /// No child processes
12pub const EDEADLK = 11; /// Resource deadlock avoided
13
14pub const ENOMEM = 12; /// Cannot allocate memory
15pub const EACCES = 13; /// Permission denied
16pub const EFAULT = 14; /// Bad address
17pub const ENOTBLK = 15; /// Block device required
18pub const EBUSY = 16; /// Device / Resource busy
19pub const EEXIST = 17; /// File exists
20pub const EXDEV = 18; /// Cross-device link
21pub const ENODEV = 19; /// Operation not supported by device
22pub const ENOTDIR = 20; /// Not a directory
23pub const EISDIR = 21; /// Is a directory
24pub const EINVAL = 22; /// Invalid argument
25pub const ENFILE = 23; /// Too many open files in system
26pub const EMFILE = 24; /// Too many open files
27pub const ENOTTY = 25; /// Inappropriate ioctl for device
28pub const ETXTBSY = 26; /// Text file busy
29pub const EFBIG = 27; /// File too large
30pub const ENOSPC = 28; /// No space left on device
31pub const ESPIPE = 29; /// Illegal seek
32pub const EROFS = 30; /// Read-only file system
33pub const EMLINK = 31; /// Too many links
34pub const EPIPE = 32; /// Broken pipe
4/// No such file or directory
5pub const ENOENT = 2;
6
7/// No such process
8pub const ESRCH = 3;
9
10/// Interrupted system call
11pub const EINTR = 4;
12
13/// Input/output error
14pub const EIO = 5;
15
16/// Device not configured
17pub const ENXIO = 6;
18
19/// Argument list too long
20pub const E2BIG = 7;
21
22/// Exec format error
23pub const ENOEXEC = 8;
24
25/// Bad file descriptor
26pub const EBADF = 9;
27
28/// No child processes
29pub const ECHILD = 10;
30
31/// Resource deadlock avoided
32pub const EDEADLK = 11;
33
34/// Cannot allocate memory
35pub const ENOMEM = 12;
36
37/// Permission denied
38pub const EACCES = 13;
39
40/// Bad address
41pub const EFAULT = 14;
42
43/// Block device required
44pub const ENOTBLK = 15;
45
46/// Device / Resource busy
47pub const EBUSY = 16;
48
49/// File exists
50pub const EEXIST = 17;
51
52/// Cross-device link
53pub const EXDEV = 18;
54
55/// Operation not supported by device
56pub const ENODEV = 19;
57
58/// Not a directory
59pub const ENOTDIR = 20;
60
61/// Is a directory
62pub const EISDIR = 21;
63
64/// Invalid argument
65pub const EINVAL = 22;
66
67/// Too many open files in system
68pub const ENFILE = 23;
69
70/// Too many open files
71pub const EMFILE = 24;
72
73/// Inappropriate ioctl for device
74pub const ENOTTY = 25;
75
76/// Text file busy
77pub const ETXTBSY = 26;
78
79/// File too large
80pub const EFBIG = 27;
81
82/// No space left on device
83pub const ENOSPC = 28;
84
85/// Illegal seek
86pub const ESPIPE = 29;
87
88/// Read-only file system
89pub const EROFS = 30;
90
91/// Too many links
92pub const EMLINK = 31;
93/// Broken pipe
3594
3695// math software
37pub const EDOM = 33; /// Numerical argument out of domain
38pub const ERANGE = 34; /// Result too large
96pub const EPIPE = 32;
97
98/// Numerical argument out of domain
99pub const EDOM = 33;
100/// Result too large
39101
40102// non-blocking and interrupt i/o
41pub const EAGAIN = 35; /// Resource temporarily unavailable
42pub const EWOULDBLOCK = EAGAIN; /// Operation would block
43pub const EINPROGRESS = 36; /// Operation now in progress
44pub const EALREADY = 37; /// Operation already in progress
103pub const ERANGE = 34;
104
105/// Resource temporarily unavailable
106pub const EAGAIN = 35;
107
108/// Operation would block
109pub const EWOULDBLOCK = EAGAIN;
110
111/// Operation now in progress
112pub const EINPROGRESS = 36;
113/// Operation already in progress
45114
46115// ipc/network software -- argument errors
47pub const ENOTSOCK = 38; /// Socket operation on non-socket
48pub const EDESTADDRREQ = 39; /// Destination address required
49pub const EMSGSIZE = 40; /// Message too long
50pub const EPROTOTYPE = 41; /// Protocol wrong type for socket
51pub const ENOPROTOOPT = 42; /// Protocol not available
52pub const EPROTONOSUPPORT = 43; /// Protocol not supported
116pub const EALREADY = 37;
117
118/// Socket operation on non-socket
119pub const ENOTSOCK = 38;
120
121/// Destination address required
122pub const EDESTADDRREQ = 39;
123
124/// Message too long
125pub const EMSGSIZE = 40;
126
127/// Protocol wrong type for socket
128pub const EPROTOTYPE = 41;
129
130/// Protocol not available
131pub const ENOPROTOOPT = 42;
132
133/// Protocol not supported
134pub const EPROTONOSUPPORT = 43;
135
136/// Socket type not supported
137pub const ESOCKTNOSUPPORT = 44;
53138
54pub const ESOCKTNOSUPPORT = 44; /// Socket type not supported
139/// Operation not supported
140pub const ENOTSUP = 45;
55141
56pub const ENOTSUP = 45; /// Operation not supported
142/// Protocol family not supported
143pub const EPFNOSUPPORT = 46;
57144
58pub const EPFNOSUPPORT = 46; /// Protocol family not supported
59pub const EAFNOSUPPORT = 47; /// Address family not supported by protocol family
60pub const EADDRINUSE = 48; /// Address already in use
61pub const EADDRNOTAVAIL = 49; /// Can't assign requested address
145/// Address family not supported by protocol family
146pub const EAFNOSUPPORT = 47;
147
148/// Address already in use
149pub const EADDRINUSE = 48;
150/// Can't assign requested address
62151
63152// ipc/network software -- operational errors
64pub const ENETDOWN = 50; /// Network is down
65pub const ENETUNREACH = 51; /// Network is unreachable
66pub const ENETRESET = 52; /// Network dropped connection on reset
67pub const ECONNABORTED = 53; /// Software caused connection abort
68pub const ECONNRESET = 54; /// Connection reset by peer
69pub const ENOBUFS = 55; /// No buffer space available
70pub const EISCONN = 56; /// Socket is already connected
71pub const ENOTCONN = 57; /// Socket is not connected
153pub const EADDRNOTAVAIL = 49;
154
155/// Network is down
156pub const ENETDOWN = 50;
157
158/// Network is unreachable
159pub const ENETUNREACH = 51;
160
161/// Network dropped connection on reset
162pub const ENETRESET = 52;
163
164/// Software caused connection abort
165pub const ECONNABORTED = 53;
166
167/// Connection reset by peer
168pub const ECONNRESET = 54;
169
170/// No buffer space available
171pub const ENOBUFS = 55;
172
173/// Socket is already connected
174pub const EISCONN = 56;
175
176/// Socket is not connected
177pub const ENOTCONN = 57;
178
179/// Can't send after socket shutdown
180pub const ESHUTDOWN = 58;
72181
73pub const ESHUTDOWN = 58; /// Can't send after socket shutdown
74pub const ETOOMANYREFS = 59; /// Too many references: can't splice
182/// Too many references: can't splice
183pub const ETOOMANYREFS = 59;
75184
76pub const ETIMEDOUT = 60; /// Operation timed out
77pub const ECONNREFUSED = 61; /// Connection refused
185/// Operation timed out
186pub const ETIMEDOUT = 60;
78187
79pub const ELOOP = 62; /// Too many levels of symbolic links
80pub const ENAMETOOLONG = 63; /// File name too long
188/// Connection refused
189pub const ECONNREFUSED = 61;
81190
82pub const EHOSTDOWN = 64; /// Host is down
83pub const EHOSTUNREACH = 65; /// No route to host
84pub const ENOTEMPTY = 66; /// Directory not empty
191/// Too many levels of symbolic links
192pub const ELOOP = 62;
193
194/// File name too long
195pub const ENAMETOOLONG = 63;
196
197/// Host is down
198pub const EHOSTDOWN = 64;
199
200/// No route to host
201pub const EHOSTUNREACH = 65;
202/// Directory not empty
85203
86204// quotas & mush
87pub const EPROCLIM = 67; /// Too many processes
88pub const EUSERS = 68; /// Too many users
89pub const EDQUOT = 69; /// Disc quota exceeded
205pub const ENOTEMPTY = 66;
206
207/// Too many processes
208pub const EPROCLIM = 67;
209
210/// Too many users
211pub const EUSERS = 68;
212/// Disc quota exceeded
90213
91214// Network File System
92pub const ESTALE = 70; /// Stale NFS file handle
93pub const EREMOTE = 71; /// Too many levels of remote in path
94pub const EBADRPC = 72; /// RPC struct is bad
95pub const ERPCMISMATCH = 73; /// RPC version wrong
96pub const EPROGUNAVAIL = 74; /// RPC prog. not avail
97pub const EPROGMISMATCH = 75; /// Program version wrong
98pub const EPROCUNAVAIL = 76; /// Bad procedure for program
215pub const EDQUOT = 69;
216
217/// Stale NFS file handle
218pub const ESTALE = 70;
219
220/// Too many levels of remote in path
221pub const EREMOTE = 71;
222
223/// RPC struct is bad
224pub const EBADRPC = 72;
225
226/// RPC version wrong
227pub const ERPCMISMATCH = 73;
228
229/// RPC prog. not avail
230pub const EPROGUNAVAIL = 74;
99231
100pub const ENOLCK = 77; /// No locks available
101pub const ENOSYS = 78; /// Function not implemented
232/// Program version wrong
233pub const EPROGMISMATCH = 75;
102234
103pub const EFTYPE = 79; /// Inappropriate file type or format
104pub const EAUTH = 80; /// Authentication error
105pub const ENEEDAUTH = 81; /// Need authenticator
235/// Bad procedure for program
236pub const EPROCUNAVAIL = 76;
237
238/// No locks available
239pub const ENOLCK = 77;
240
241/// Function not implemented
242pub const ENOSYS = 78;
243
244/// Inappropriate file type or format
245pub const EFTYPE = 79;
246
247/// Authentication error
248pub const EAUTH = 80;
249/// Need authenticator
106250
107251// Intelligent device errors
108pub const EPWROFF = 82; /// Device power is off
109pub const EDEVERR = 83; /// Device error, e.g. paper out
252pub const ENEEDAUTH = 81;
253
254/// Device power is off
255pub const EPWROFF = 82;
110256
111pub const EOVERFLOW = 84; /// Value too large to be stored in data type
257/// Device error, e.g. paper out
258pub const EDEVERR = 83;
259/// Value too large to be stored in data type
112260
113261// Program loading errors
114pub const EBADEXEC = 85; /// Bad executable
115pub const EBADARCH = 86; /// Bad CPU type in executable
116pub const ESHLIBVERS = 87; /// Shared library version mismatch
117pub const EBADMACHO = 88; /// Malformed Macho file
262pub const EOVERFLOW = 84;
263
264/// Bad executable
265pub const EBADEXEC = 85;
266
267/// Bad CPU type in executable
268pub const EBADARCH = 86;
269
270/// Shared library version mismatch
271pub const ESHLIBVERS = 87;
272
273/// Malformed Macho file
274pub const EBADMACHO = 88;
275
276/// Operation canceled
277pub const ECANCELED = 89;
278
279/// Identifier removed
280pub const EIDRM = 90;
281
282/// No message of desired type
283pub const ENOMSG = 91;
284
285/// Illegal byte sequence
286pub const EILSEQ = 92;
287
288/// Attribute not found
289pub const ENOATTR = 93;
290
291/// Bad message
292pub const EBADMSG = 94;
293
294/// Reserved
295pub const EMULTIHOP = 95;
296
297/// No message available on STREAM
298pub const ENODATA = 96;
299
300/// Reserved
301pub const ENOLINK = 97;
302
303/// No STREAM resources
304pub const ENOSR = 98;
305
306/// Not a STREAM
307pub const ENOSTR = 99;
118308
119pub const ECANCELED = 89; /// Operation canceled
309/// Protocol error
310pub const EPROTO = 100;
120311
121pub const EIDRM = 90; /// Identifier removed
122pub const ENOMSG = 91; /// No message of desired type
123pub const EILSEQ = 92; /// Illegal byte sequence
124pub const ENOATTR = 93; /// Attribute not found
312/// STREAM ioctl timeout
313pub const ETIME = 101;
125314
126pub const EBADMSG = 94; /// Bad message
127pub const EMULTIHOP = 95; /// Reserved
128pub const ENODATA = 96; /// No message available on STREAM
129pub const ENOLINK = 97; /// Reserved
130pub const ENOSR = 98; /// No STREAM resources
131pub const ENOSTR = 99; /// Not a STREAM
132pub const EPROTO = 100; /// Protocol error
133pub const ETIME = 101; /// STREAM ioctl timeout
315/// No such policy registered
316pub const ENOPOLICY = 103;
134317
135pub const ENOPOLICY = 103; /// No such policy registered
318/// State not recoverable
319pub const ENOTRECOVERABLE = 104;
136320
137pub const ENOTRECOVERABLE = 104; /// State not recoverable
138pub const EOWNERDEAD = 105; /// Previous owner died
321/// Previous owner died
322pub const EOWNERDEAD = 105;
139323
140pub const EQFULL = 106; /// Interface output queue is full
141pub const ELAST = 106; /// Must be equal largest errno
324/// Interface output queue is full
325pub const EQFULL = 106;
142326
327/// Must be equal largest errno
328pub const ELAST = 106;
std/os/epoch.zig+23-23
......@@ -1,26 +1,26 @@
11/// Epoch reference times in terms of their difference from
22/// posix epoch in seconds.
3pub const posix = 0; //Jan 01, 1970 AD
4pub const dos = 315532800; //Jan 01, 1980 AD
5pub const ios = 978307200; //Jan 01, 2001 AD
6pub const openvms = -3506716800; //Nov 17, 1858 AD
7pub const zos = -2208988800; //Jan 01, 1900 AD
8pub const windows = -11644473600; //Jan 01, 1601 AD
9pub const amiga = 252460800; //Jan 01, 1978 AD
10pub const pickos = -63244800; //Dec 31, 1967 AD
11pub const gps = 315964800; //Jan 06, 1980 AD
12pub const clr = -62135769600; //Jan 01, 0001 AD
3pub const posix = 0; //Jan 01, 1970 AD
4pub const dos = 315532800; //Jan 01, 1980 AD
5pub const ios = 978307200; //Jan 01, 2001 AD
6pub const openvms = -3506716800; //Nov 17, 1858 AD
7pub const zos = -2208988800; //Jan 01, 1900 AD
8pub const windows = -11644473600; //Jan 01, 1601 AD
9pub const amiga = 252460800; //Jan 01, 1978 AD
10pub const pickos = -63244800; //Dec 31, 1967 AD
11pub const gps = 315964800; //Jan 06, 1980 AD
12pub const clr = -62135769600; //Jan 01, 0001 AD
1313
14pub const unix = posix;
15pub const android = posix;
16pub const os2 = dos;
17pub const bios = dos;
18pub const vfat = dos;
19pub const ntfs = windows;
20pub const ntp = zos;
21pub const jbase = pickos;
22pub const aros = amiga;
23pub const morphos = amiga;
24pub const brew = gps;
25pub const atsc = gps;
26pub const go = clr;
\ No newline at end of file
14pub const unix = posix;
15pub const android = posix;
16pub const os2 = dos;
17pub const bios = dos;
18pub const vfat = dos;
19pub const ntfs = windows;
20pub const ntp = zos;
21pub const jbase = pickos;
22pub const aros = amiga;
23pub const morphos = amiga;
24pub const brew = gps;
25pub const atsc = gps;
26pub const go = clr;
std/os/file.zig+35-24
......@@ -21,12 +21,18 @@ pub const File = struct {
2121 /// Call close to clean up.
2222 pub fn openRead(allocator: &mem.Allocator, path: []const u8) OpenError!File {
2323 if (is_posix) {
24 const flags = posix.O_LARGEFILE|posix.O_RDONLY;
24 const flags = posix.O_LARGEFILE | posix.O_RDONLY;
2525 const fd = try os.posixOpen(allocator, path, flags, 0);
2626 return openHandle(fd);
2727 } else if (is_windows) {
28 const handle = try os.windowsOpen(allocator, path, windows.GENERIC_READ, windows.FILE_SHARE_READ,
29 windows.OPEN_EXISTING, windows.FILE_ATTRIBUTE_NORMAL);
28 const handle = try os.windowsOpen(
29 allocator,
30 path,
31 windows.GENERIC_READ,
32 windows.FILE_SHARE_READ,
33 windows.OPEN_EXISTING,
34 windows.FILE_ATTRIBUTE_NORMAL,
35 );
3036 return openHandle(handle);
3137 } else {
3238 @compileError("TODO implement openRead for this OS");
......@@ -36,7 +42,6 @@ pub const File = struct {
3642 /// Calls `openWriteMode` with os.default_file_mode for the mode.
3743 pub fn openWrite(allocator: &mem.Allocator, path: []const u8) OpenError!File {
3844 return openWriteMode(allocator, path, os.default_file_mode);
39
4045 }
4146
4247 /// If the path does not exist it will be created.
......@@ -45,18 +50,22 @@ pub const File = struct {
4550 /// Call close to clean up.
4651 pub fn openWriteMode(allocator: &mem.Allocator, path: []const u8, file_mode: os.FileMode) OpenError!File {
4752 if (is_posix) {
48 const flags = posix.O_LARGEFILE|posix.O_WRONLY|posix.O_CREAT|posix.O_CLOEXEC|posix.O_TRUNC;
53 const flags = posix.O_LARGEFILE | posix.O_WRONLY | posix.O_CREAT | posix.O_CLOEXEC | posix.O_TRUNC;
4954 const fd = try os.posixOpen(allocator, path, flags, file_mode);
5055 return openHandle(fd);
5156 } else if (is_windows) {
52 const handle = try os.windowsOpen(allocator, path, windows.GENERIC_WRITE,
53 windows.FILE_SHARE_WRITE|windows.FILE_SHARE_READ|windows.FILE_SHARE_DELETE,
54 windows.CREATE_ALWAYS, windows.FILE_ATTRIBUTE_NORMAL);
57 const handle = try os.windowsOpen(
58 allocator,
59 path,
60 windows.GENERIC_WRITE,
61 windows.FILE_SHARE_WRITE | windows.FILE_SHARE_READ | windows.FILE_SHARE_DELETE,
62 windows.CREATE_ALWAYS,
63 windows.FILE_ATTRIBUTE_NORMAL,
64 );
5565 return openHandle(handle);
5666 } else {
5767 @compileError("TODO implement openWriteMode for this OS");
5868 }
59
6069 }
6170
6271 /// If the path does not exist it will be created.
......@@ -65,24 +74,26 @@ pub const File = struct {
6574 /// Call close to clean up.
6675 pub fn openWriteNoClobber(allocator: &mem.Allocator, path: []const u8, file_mode: os.FileMode) OpenError!File {
6776 if (is_posix) {
68 const flags = posix.O_LARGEFILE|posix.O_WRONLY|posix.O_CREAT|posix.O_CLOEXEC|posix.O_EXCL;
77 const flags = posix.O_LARGEFILE | posix.O_WRONLY | posix.O_CREAT | posix.O_CLOEXEC | posix.O_EXCL;
6978 const fd = try os.posixOpen(allocator, path, flags, file_mode);
7079 return openHandle(fd);
7180 } else if (is_windows) {
72 const handle = try os.windowsOpen(allocator, path, windows.GENERIC_WRITE,
73 windows.FILE_SHARE_WRITE|windows.FILE_SHARE_READ|windows.FILE_SHARE_DELETE,
74 windows.CREATE_NEW, windows.FILE_ATTRIBUTE_NORMAL);
81 const handle = try os.windowsOpen(
82 allocator,
83 path,
84 windows.GENERIC_WRITE,
85 windows.FILE_SHARE_WRITE | windows.FILE_SHARE_READ | windows.FILE_SHARE_DELETE,
86 windows.CREATE_NEW,
87 windows.FILE_ATTRIBUTE_NORMAL,
88 );
7589 return openHandle(handle);
7690 } else {
7791 @compileError("TODO implement openWriteMode for this OS");
7892 }
79
8093 }
8194
8295 pub fn openHandle(handle: os.FileHandle) File {
83 return File {
84 .handle = handle,
85 };
96 return File{ .handle = handle };
8697 }
8798
8899 pub fn access(allocator: &mem.Allocator, path: []const u8, file_mode: os.FileMode) !bool {
......@@ -217,7 +228,7 @@ pub const File = struct {
217228 return result;
218229 },
219230 Os.windows => {
220 var pos : windows.LARGE_INTEGER = undefined;
231 var pos: windows.LARGE_INTEGER = undefined;
221232 if (windows.SetFilePointerEx(self.handle, 0, &pos, windows.FILE_CURRENT) == 0) {
222233 const err = windows.GetLastError();
223234 return switch (err) {
......@@ -268,7 +279,7 @@ pub const File = struct {
268279 }
269280 }
270281
271 pub const ModeError = error {
282 pub const ModeError = error{
272283 BadFd,
273284 SystemResources,
274285 Unexpected,
......@@ -296,7 +307,7 @@ pub const File = struct {
296307 }
297308 }
298309
299 pub const ReadError = error {};
310 pub const ReadError = error{};
300311
301312 pub fn read(self: &File, buffer: []u8) !usize {
302313 if (is_posix) {
......@@ -306,12 +317,12 @@ pub const File = struct {
306317 const read_err = posix.getErrno(amt_read);
307318 if (read_err > 0) {
308319 switch (read_err) {
309 posix.EINTR => continue,
320 posix.EINTR => continue,
310321 posix.EINVAL => unreachable,
311322 posix.EFAULT => unreachable,
312 posix.EBADF => return error.BadFd,
313 posix.EIO => return error.Io,
314 else => return os.unexpectedErrorPosix(read_err),
323 posix.EBADF => return error.BadFd,
324 posix.EIO => return error.Io,
325 else => return os.unexpectedErrorPosix(read_err),
315326 }
316327 }
317328 if (amt_read == 0) return index;
std/os/get_user_id.zig+3-3
......@@ -74,7 +74,7 @@ pub fn posixGetUserInfo(name: []const u8) !UserInfo {
7474 '\n' => return error.CorruptPasswordFile,
7575 else => {
7676 const digit = switch (byte) {
77 '0' ... '9' => byte - '0',
77 '0'...'9' => byte - '0',
7878 else => return error.CorruptPasswordFile,
7979 };
8080 if (@mulWithOverflow(u32, uid, 10, &uid)) return error.CorruptPasswordFile;
......@@ -83,14 +83,14 @@ pub fn posixGetUserInfo(name: []const u8) !UserInfo {
8383 },
8484 State.ReadGroupId => switch (byte) {
8585 '\n', ':' => {
86 return UserInfo {
86 return UserInfo{
8787 .uid = uid,
8888 .gid = gid,
8989 };
9090 },
9191 else => {
9292 const digit = switch (byte) {
93 '0' ... '9' => byte - '0',
93 '0'...'9' => byte - '0',
9494 else => return error.CorruptPasswordFile,
9595 };
9696 if (@mulWithOverflow(u32, gid, 10, &gid)) return error.CorruptPasswordFile;
std/os/index.zig+62-106
......@@ -3,8 +3,7 @@ const builtin = @import("builtin");
33const Os = builtin.Os;
44const is_windows = builtin.os == Os.windows;
55const is_posix = switch (builtin.os) {
6 builtin.Os.linux,
7 builtin.Os.macosx => true,
6 builtin.Os.linux, builtin.Os.macosx => true,
87 else => false,
98};
109const os = this;
......@@ -27,8 +26,7 @@ pub const linux = @import("linux/index.zig");
2726pub const zen = @import("zen.zig");
2827pub const posix = switch (builtin.os) {
2928 Os.linux => linux,
30 Os.macosx,
31 Os.ios => darwin,
29 Os.macosx, Os.ios => darwin,
3230 Os.zen => zen,
3331 else => @compileError("Unsupported OS"),
3432};
......@@ -112,8 +110,7 @@ pub fn getRandomBytes(buf: []u8) !void {
112110 }
113111 return;
114112 },
115 Os.macosx,
116 Os.ios => {
113 Os.macosx, Os.ios => {
117114 const fd = try posixOpenC(c"/dev/urandom", posix.O_RDONLY | posix.O_CLOEXEC, 0);
118115 defer close(fd);
119116
......@@ -175,9 +172,7 @@ pub fn abort() noreturn {
175172 c.abort();
176173 }
177174 switch (builtin.os) {
178 Os.linux,
179 Os.macosx,
180 Os.ios => {
175 Os.linux, Os.macosx, Os.ios => {
181176 _ = posix.raise(posix.SIGABRT);
182177 _ = posix.raise(posix.SIGKILL);
183178 while (true) {}
......@@ -199,9 +194,7 @@ pub fn exit(status: u8) noreturn {
199194 c.exit(status);
200195 }
201196 switch (builtin.os) {
202 Os.linux,
203 Os.macosx,
204 Os.ios => {
197 Os.linux, Os.macosx, Os.ios => {
205198 posix.exit(status);
206199 },
207200 Os.windows => {
......@@ -250,14 +243,12 @@ pub fn posixRead(fd: i32, buf: []u8) !void {
250243 if (err > 0) {
251244 return switch (err) {
252245 posix.EINTR => continue,
253 posix.EINVAL,
254 posix.EFAULT => unreachable,
246 posix.EINVAL, posix.EFAULT => unreachable,
255247 posix.EAGAIN => error.WouldBlock,
256248 posix.EBADF => error.FileClosed,
257249 posix.EIO => error.InputOutput,
258250 posix.EISDIR => error.IsDir,
259 posix.ENOBUFS,
260 posix.ENOMEM => error.SystemResources,
251 posix.ENOBUFS, posix.ENOMEM => error.SystemResources,
261252 else => unexpectedErrorPosix(err),
262253 };
263254 }
......@@ -292,8 +283,7 @@ pub fn posixWrite(fd: i32, bytes: []const u8) !void {
292283 if (write_err > 0) {
293284 return switch (write_err) {
294285 posix.EINTR => continue,
295 posix.EINVAL,
296 posix.EFAULT => unreachable,
286 posix.EINVAL, posix.EFAULT => unreachable,
297287 posix.EAGAIN => PosixWriteError.WouldBlock,
298288 posix.EBADF => PosixWriteError.FileClosed,
299289 posix.EDESTADDRREQ => PosixWriteError.DestinationAddressRequired,
......@@ -349,8 +339,7 @@ pub fn posixOpenC(file_path: &const u8, flags: u32, perm: usize) !i32 {
349339 posix.EFAULT => unreachable,
350340 posix.EINVAL => unreachable,
351341 posix.EACCES => return PosixOpenError.AccessDenied,
352 posix.EFBIG,
353 posix.EOVERFLOW => return PosixOpenError.FileTooBig,
342 posix.EFBIG, posix.EOVERFLOW => return PosixOpenError.FileTooBig,
354343 posix.EISDIR => return PosixOpenError.IsDir,
355344 posix.ELOOP => return PosixOpenError.SymLinkLoop,
356345 posix.EMFILE => return PosixOpenError.ProcessFdQuotaExceeded,
......@@ -375,8 +364,7 @@ pub fn posixDup2(old_fd: i32, new_fd: i32) !void {
375364 const err = posix.getErrno(posix.dup2(old_fd, new_fd));
376365 if (err > 0) {
377366 return switch (err) {
378 posix.EBUSY,
379 posix.EINTR => continue,
367 posix.EBUSY, posix.EINTR => continue,
380368 posix.EMFILE => error.ProcessFdQuotaExceeded,
381369 posix.EINVAL => unreachable,
382370 else => unexpectedErrorPosix(err),
......@@ -493,17 +481,10 @@ fn posixExecveErrnoToErr(err: usize) PosixExecveError {
493481 assert(err > 0);
494482 return switch (err) {
495483 posix.EFAULT => unreachable,
496 posix.E2BIG,
497 posix.EMFILE,
498 posix.ENAMETOOLONG,
499 posix.ENFILE,
500 posix.ENOMEM => error.SystemResources,
501 posix.EACCES,
502 posix.EPERM => error.AccessDenied,
503 posix.EINVAL,
504 posix.ENOEXEC => error.InvalidExe,
505 posix.EIO,
506 posix.ELOOP => error.FileSystem,
484 posix.E2BIG, posix.EMFILE, posix.ENAMETOOLONG, posix.ENFILE, posix.ENOMEM => error.SystemResources,
485 posix.EACCES, posix.EPERM => error.AccessDenied,
486 posix.EINVAL, posix.ENOEXEC => error.InvalidExe,
487 posix.EIO, posix.ELOOP => error.FileSystem,
507488 posix.EISDIR => error.IsDir,
508489 posix.ENOENT => error.FileNotFound,
509490 posix.ENOTDIR => error.NotDir,
......@@ -717,10 +698,8 @@ pub fn symLinkPosix(allocator: &Allocator, existing_path: []const u8, new_path:
717698 const err = posix.getErrno(posix.symlink(existing_buf.ptr, new_buf.ptr));
718699 if (err > 0) {
719700 return switch (err) {
720 posix.EFAULT,
721 posix.EINVAL => unreachable,
722 posix.EACCES,
723 posix.EPERM => error.AccessDenied,
701 posix.EFAULT, posix.EINVAL => unreachable,
702 posix.EACCES, posix.EPERM => error.AccessDenied,
724703 posix.EDQUOT => error.DiskQuota,
725704 posix.EEXIST => error.PathAlreadyExists,
726705 posix.EIO => error.FileSystem,
......@@ -787,8 +766,7 @@ pub fn deleteFileWindows(allocator: &Allocator, file_path: []const u8) !void {
787766 return switch (err) {
788767 windows.ERROR.FILE_NOT_FOUND => error.FileNotFound,
789768 windows.ERROR.ACCESS_DENIED => error.AccessDenied,
790 windows.ERROR.FILENAME_EXCED_RANGE,
791 windows.ERROR.INVALID_PARAMETER => error.NameTooLong,
769 windows.ERROR.FILENAME_EXCED_RANGE, windows.ERROR.INVALID_PARAMETER => error.NameTooLong,
792770 else => unexpectedErrorWindows(err),
793771 };
794772 }
......@@ -804,11 +782,9 @@ pub fn deleteFilePosix(allocator: &Allocator, file_path: []const u8) !void {
804782 const err = posix.getErrno(posix.unlink(buf.ptr));
805783 if (err > 0) {
806784 return switch (err) {
807 posix.EACCES,
808 posix.EPERM => error.AccessDenied,
785 posix.EACCES, posix.EPERM => error.AccessDenied,
809786 posix.EBUSY => error.FileBusy,
810 posix.EFAULT,
811 posix.EINVAL => unreachable,
787 posix.EFAULT, posix.EINVAL => unreachable,
812788 posix.EIO => error.FileSystem,
813789 posix.EISDIR => error.IsDir,
814790 posix.ELOOP => error.SymLinkLoop,
......@@ -948,12 +924,10 @@ pub fn rename(allocator: &Allocator, old_path: []const u8, new_path: []const u8)
948924 const err = posix.getErrno(posix.rename(old_buf.ptr, new_buf.ptr));
949925 if (err > 0) {
950926 return switch (err) {
951 posix.EACCES,
952 posix.EPERM => error.AccessDenied,
927 posix.EACCES, posix.EPERM => error.AccessDenied,
953928 posix.EBUSY => error.FileBusy,
954929 posix.EDQUOT => error.DiskQuota,
955 posix.EFAULT,
956 posix.EINVAL => unreachable,
930 posix.EFAULT, posix.EINVAL => unreachable,
957931 posix.EISDIR => error.IsDir,
958932 posix.ELOOP => error.SymLinkLoop,
959933 posix.EMLINK => error.LinkQuotaExceeded,
......@@ -962,8 +936,7 @@ pub fn rename(allocator: &Allocator, old_path: []const u8, new_path: []const u8)
962936 posix.ENOTDIR => error.NotDir,
963937 posix.ENOMEM => error.SystemResources,
964938 posix.ENOSPC => error.NoSpaceLeft,
965 posix.EEXIST,
966 posix.ENOTEMPTY => error.PathAlreadyExists,
939 posix.EEXIST, posix.ENOTEMPTY => error.PathAlreadyExists,
967940 posix.EROFS => error.ReadOnlyFileSystem,
968941 posix.EXDEV => error.RenameAcrossMountPoints,
969942 else => unexpectedErrorPosix(err),
......@@ -1001,8 +974,7 @@ pub fn makeDirPosix(allocator: &Allocator, dir_path: []const u8) !void {
1001974 const err = posix.getErrno(posix.mkdir(path_buf.ptr, 0o755));
1002975 if (err > 0) {
1003976 return switch (err) {
1004 posix.EACCES,
1005 posix.EPERM => error.AccessDenied,
977 posix.EACCES, posix.EPERM => error.AccessDenied,
1006978 posix.EDQUOT => error.DiskQuota,
1007979 posix.EEXIST => error.PathAlreadyExists,
1008980 posix.EFAULT => unreachable,
......@@ -1065,18 +1037,15 @@ pub fn deleteDir(allocator: &Allocator, dir_path: []const u8) !void {
10651037 const err = posix.getErrno(posix.rmdir(path_buf.ptr));
10661038 if (err > 0) {
10671039 return switch (err) {
1068 posix.EACCES,
1069 posix.EPERM => error.AccessDenied,
1040 posix.EACCES, posix.EPERM => error.AccessDenied,
10701041 posix.EBUSY => error.FileBusy,
1071 posix.EFAULT,
1072 posix.EINVAL => unreachable,
1042 posix.EFAULT, posix.EINVAL => unreachable,
10731043 posix.ELOOP => error.SymLinkLoop,
10741044 posix.ENAMETOOLONG => error.NameTooLong,
10751045 posix.ENOENT => error.FileNotFound,
10761046 posix.ENOMEM => error.SystemResources,
10771047 posix.ENOTDIR => error.NotDir,
1078 posix.EEXIST,
1079 posix.ENOTEMPTY => error.DirNotEmpty,
1048 posix.EEXIST, posix.ENOTEMPTY => error.DirNotEmpty,
10801049 posix.EROFS => error.ReadOnlyFileSystem,
10811050 else => unexpectedErrorPosix(err),
10821051 };
......@@ -1128,7 +1097,8 @@ pub fn deleteTree(allocator: &Allocator, full_path: []const u8) DeleteTreeError!
11281097 error.NotDir,
11291098 error.FileSystem,
11301099 error.FileBusy,
1131 error.Unexpected => return err,
1100 error.Unexpected,
1101 => return err,
11321102 }
11331103 {
11341104 var dir = Dir.open(allocator, full_path) catch |err| switch (err) {
......@@ -1152,7 +1122,8 @@ pub fn deleteTree(allocator: &Allocator, full_path: []const u8) DeleteTreeError!
11521122 error.SystemResources,
11531123 error.NoSpaceLeft,
11541124 error.PathAlreadyExists,
1155 error.Unexpected => return err,
1125 error.Unexpected,
1126 => return err,
11561127 };
11571128 defer dir.close();
11581129
......@@ -1182,8 +1153,7 @@ pub const Dir = struct {
11821153 end_index: usize,
11831154
11841155 const darwin_seek_t = switch (builtin.os) {
1185 Os.macosx,
1186 Os.ios => i64,
1156 Os.macosx, Os.ios => i64,
11871157 else => void,
11881158 };
11891159
......@@ -1208,13 +1178,16 @@ pub const Dir = struct {
12081178 const fd = switch (builtin.os) {
12091179 Os.windows => @compileError("TODO support Dir.open for windows"),
12101180 Os.linux => try posixOpen(allocator, dir_path, posix.O_RDONLY | posix.O_DIRECTORY | posix.O_CLOEXEC, 0),
1211 Os.macosx,
1212 Os.ios => try posixOpen(allocator, dir_path, posix.O_RDONLY | posix.O_NONBLOCK | posix.O_DIRECTORY | posix.O_CLOEXEC, 0),
1181 Os.macosx, Os.ios => try posixOpen(
1182 allocator,
1183 dir_path,
1184 posix.O_RDONLY | posix.O_NONBLOCK | posix.O_DIRECTORY | posix.O_CLOEXEC,
1185 0,
1186 ),
12131187 else => @compileError("Dir.open is not supported for this platform"),
12141188 };
12151189 const darwin_seek_init = switch (builtin.os) {
1216 Os.macosx,
1217 Os.ios => 0,
1190 Os.macosx, Os.ios => 0,
12181191 else => {},
12191192 };
12201193 return Dir{
......@@ -1237,8 +1210,7 @@ pub const Dir = struct {
12371210 pub fn next(self: &Dir) !?Entry {
12381211 switch (builtin.os) {
12391212 Os.linux => return self.nextLinux(),
1240 Os.macosx,
1241 Os.ios => return self.nextDarwin(),
1213 Os.macosx, Os.ios => return self.nextDarwin(),
12421214 Os.windows => return self.nextWindows(),
12431215 else => @compileError("Dir.next not supported on " ++ @tagName(builtin.os)),
12441216 }
......@@ -1256,9 +1228,7 @@ pub const Dir = struct {
12561228 const err = posix.getErrno(result);
12571229 if (err > 0) {
12581230 switch (err) {
1259 posix.EBADF,
1260 posix.EFAULT,
1261 posix.ENOTDIR => unreachable,
1231 posix.EBADF, posix.EFAULT, posix.ENOTDIR => unreachable,
12621232 posix.EINVAL => {
12631233 self.buf = try self.allocator.realloc(u8, self.buf, self.buf.len * 2);
12641234 continue;
......@@ -1317,9 +1287,7 @@ pub const Dir = struct {
13171287 const err = posix.getErrno(result);
13181288 if (err > 0) {
13191289 switch (err) {
1320 posix.EBADF,
1321 posix.EFAULT,
1322 posix.ENOTDIR => unreachable,
1290 posix.EBADF, posix.EFAULT, posix.ENOTDIR => unreachable,
13231291 posix.EINVAL => {
13241292 self.buf = try self.allocator.realloc(u8, self.buf, self.buf.len * 2);
13251293 continue;
......@@ -1402,8 +1370,7 @@ pub fn readLink(allocator: &Allocator, pathname: []const u8) ![]u8 {
14021370 if (err > 0) {
14031371 return switch (err) {
14041372 posix.EACCES => error.AccessDenied,
1405 posix.EFAULT,
1406 posix.EINVAL => unreachable,
1373 posix.EFAULT, posix.EINVAL => unreachable,
14071374 posix.EIO => error.FileSystem,
14081375 posix.ELOOP => error.SymLinkLoop,
14091376 posix.ENAMETOOLONG => error.NameTooLong,
......@@ -1545,8 +1512,7 @@ pub const ArgIteratorWindows = struct {
15451512 const byte = self.cmd_line[self.index];
15461513 switch (byte) {
15471514 0 => return null,
1548 ' ',
1549 '\t' => continue,
1515 ' ', '\t' => continue,
15501516 else => break,
15511517 }
15521518 }
......@@ -1560,8 +1526,7 @@ pub const ArgIteratorWindows = struct {
15601526 const byte = self.cmd_line[self.index];
15611527 switch (byte) {
15621528 0 => return false,
1563 ' ',
1564 '\t' => continue,
1529 ' ', '\t' => continue,
15651530 else => break,
15661531 }
15671532 }
......@@ -1580,8 +1545,7 @@ pub const ArgIteratorWindows = struct {
15801545 '\\' => {
15811546 backslash_count += 1;
15821547 },
1583 ' ',
1584 '\t' => {
1548 ' ', '\t' => {
15851549 if (self.seen_quote_count % 2 == 0 or self.seen_quote_count == self.quote_count) {
15861550 return true;
15871551 }
......@@ -1621,8 +1585,7 @@ pub const ArgIteratorWindows = struct {
16211585 '\\' => {
16221586 backslash_count += 1;
16231587 },
1624 ' ',
1625 '\t' => {
1588 ' ', '\t' => {
16261589 try self.emitBackslashes(&buf, backslash_count);
16271590 backslash_count = 0;
16281591 if (self.seen_quote_count % 2 == 1 and self.seen_quote_count != self.quote_count) {
......@@ -1840,8 +1803,7 @@ pub fn openSelfExe() !os.File {
18401803 var fixed_allocator = std.heap.FixedBufferAllocator.init(fixed_buffer_mem[0..]);
18411804 return os.File.openRead(&fixed_allocator.allocator, proc_file_path);
18421805 },
1843 Os.macosx,
1844 Os.ios => {
1806 Os.macosx, Os.ios => {
18451807 var fixed_buffer_mem: [darwin.PATH_MAX * 2]u8 = undefined;
18461808 var fixed_allocator = std.heap.FixedBufferAllocator.init(fixed_buffer_mem[0..]);
18471809 const self_exe_path = try selfExePath(&fixed_allocator.allocator);
......@@ -1853,9 +1815,7 @@ pub fn openSelfExe() !os.File {
18531815
18541816test "openSelfExe" {
18551817 switch (builtin.os) {
1856 Os.linux,
1857 Os.macosx,
1858 Os.ios => (try openSelfExe()).close(),
1818 Os.linux, Os.macosx, Os.ios => (try openSelfExe()).close(),
18591819 else => return, // Unsupported OS.
18601820 }
18611821}
......@@ -1893,8 +1853,7 @@ pub fn selfExePath(allocator: &mem.Allocator) ![]u8 {
18931853 try out_path.resize(new_len);
18941854 }
18951855 },
1896 Os.macosx,
1897 Os.ios => {
1856 Os.macosx, Os.ios => {
18981857 var u32_len: u32 = 0;
18991858 const ret1 = c._NSGetExecutablePath(undefined, &u32_len);
19001859 assert(ret1 != 0);
......@@ -1922,9 +1881,7 @@ pub fn selfExeDirPath(allocator: &mem.Allocator) ![]u8 {
19221881 const dir = path.dirname(full_exe_path);
19231882 return allocator.shrink(u8, full_exe_path, dir.len);
19241883 },
1925 Os.windows,
1926 Os.macosx,
1927 Os.ios => {
1884 Os.windows, Os.macosx, Os.ios => {
19281885 const self_exe_path = try selfExePath(allocator);
19291886 errdefer allocator.free(self_exe_path);
19301887 const dirname = os.path.dirname(self_exe_path);
......@@ -1981,8 +1938,7 @@ pub fn posixSocket(domain: u32, socket_type: u32, protocol: u32) !i32 {
19811938 posix.EINVAL => return PosixSocketError.ProtocolFamilyNotAvailable,
19821939 posix.EMFILE => return PosixSocketError.ProcessFdQuotaExceeded,
19831940 posix.ENFILE => return PosixSocketError.SystemFdQuotaExceeded,
1984 posix.ENOBUFS,
1985 posix.ENOMEM => return PosixSocketError.SystemResources,
1941 posix.ENOBUFS, posix.ENOMEM => return PosixSocketError.SystemResources,
19861942 posix.EPROTONOSUPPORT => return PosixSocketError.ProtocolNotSupported,
19871943 else => return unexpectedErrorPosix(err),
19881944 }
......@@ -1990,7 +1946,7 @@ pub fn posixSocket(domain: u32, socket_type: u32, protocol: u32) !i32 {
19901946
19911947pub const PosixBindError = error{
19921948 /// The address is protected, and the user is not the superuser.
1993 /// For UNIX domain sockets: Search permission is denied on a component
1949 /// For UNIX domain sockets: Search permission is denied on a component
19941950 /// of the path prefix.
19951951 AccessDenied,
19961952
......@@ -2151,8 +2107,7 @@ pub fn posixAccept(fd: i32, addr: &posix.sockaddr, flags: u32) PosixAcceptError!
21512107 posix.EINVAL => return PosixAcceptError.InvalidSyscall,
21522108 posix.EMFILE => return PosixAcceptError.ProcessFdQuotaExceeded,
21532109 posix.ENFILE => return PosixAcceptError.SystemFdQuotaExceeded,
2154 posix.ENOBUFS,
2155 posix.ENOMEM => return PosixAcceptError.SystemResources,
2110 posix.ENOBUFS, posix.ENOMEM => return PosixAcceptError.SystemResources,
21562111 posix.ENOTSOCK => return PosixAcceptError.FileDescriptorNotASocket,
21572112 posix.EOPNOTSUPP => return PosixAcceptError.OperationNotSupported,
21582113 posix.EPROTO => return PosixAcceptError.ProtocolFailure,
......@@ -2363,8 +2318,7 @@ pub fn posixConnectAsync(sockfd: i32, sockaddr: &const posix.sockaddr) PosixConn
23632318 const rc = posix.connect(sockfd, sockaddr, @sizeOf(posix.sockaddr));
23642319 const err = posix.getErrno(rc);
23652320 switch (err) {
2366 0,
2367 posix.EINPROGRESS => return,
2321 0, posix.EINPROGRESS => return,
23682322 else => return unexpectedErrorPosix(err),
23692323
23702324 posix.EACCES => return PosixConnectError.PermissionDenied,
......@@ -2416,7 +2370,7 @@ pub fn posixGetSockOptConnectError(sockfd: i32) PosixConnectError!void {
24162370 },
24172371 else => return unexpectedErrorPosix(err),
24182372 posix.EBADF => unreachable, // The argument sockfd is not a valid file descriptor.
2419 posix.EFAULT => unreachable, // The address pointed to by optval or optlen is not in a valid part of the process address space.
2373 posix.EFAULT => unreachable, // The address pointed to by optval or optlen is not in a valid part of the process address space.
24202374 posix.EINVAL => unreachable,
24212375 posix.ENOPROTOOPT => unreachable, // The option is unknown at the level indicated.
24222376 posix.ENOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket.
......@@ -2427,11 +2381,13 @@ pub const Thread = struct {
24272381 data: Data,
24282382
24292383 pub const use_pthreads = is_posix and builtin.link_libc;
2430 const Data = if (use_pthreads) struct {
2431 handle: c.pthread_t,
2432 stack_addr: usize,
2433 stack_len: usize,
2434 } else switch (builtin.os) {
2384 const Data = if (use_pthreads)
2385 struct {
2386 handle: c.pthread_t,
2387 stack_addr: usize,
2388 stack_len: usize,
2389 }
2390 else switch (builtin.os) {
24352391 builtin.Os.linux => struct {
24362392 pid: i32,
24372393 stack_addr: usize,
std/os/linux/errno.zig+425-144
......@@ -1,146 +1,427 @@
1pub const EPERM = 1; /// Operation not permitted
2pub const ENOENT = 2; /// No such file or directory
3pub const ESRCH = 3; /// No such process
4pub const EINTR = 4; /// Interrupted system call
5pub const EIO = 5; /// I/O error
6pub const ENXIO = 6; /// No such device or address
7pub const E2BIG = 7; /// Arg list too long
8pub const ENOEXEC = 8; /// Exec format error
9pub const EBADF = 9; /// Bad file number
10pub const ECHILD = 10; /// No child processes
11pub const EAGAIN = 11; /// Try again
12pub const ENOMEM = 12; /// Out of memory
13pub const EACCES = 13; /// Permission denied
14pub const EFAULT = 14; /// Bad address
15pub const ENOTBLK = 15; /// Block device required
16pub const EBUSY = 16; /// Device or resource busy
17pub const EEXIST = 17; /// File exists
18pub const EXDEV = 18; /// Cross-device link
19pub const ENODEV = 19; /// No such device
20pub const ENOTDIR = 20; /// Not a directory
21pub const EISDIR = 21; /// Is a directory
22pub const EINVAL = 22; /// Invalid argument
23pub const ENFILE = 23; /// File table overflow
24pub const EMFILE = 24; /// Too many open files
25pub const ENOTTY = 25; /// Not a typewriter
26pub const ETXTBSY = 26; /// Text file busy
27pub const EFBIG = 27; /// File too large
28pub const ENOSPC = 28; /// No space left on device
29pub const ESPIPE = 29; /// Illegal seek
30pub const EROFS = 30; /// Read-only file system
31pub const EMLINK = 31; /// Too many links
32pub const EPIPE = 32; /// Broken pipe
33pub const EDOM = 33; /// Math argument out of domain of func
34pub const ERANGE = 34; /// Math result not representable
35pub const EDEADLK = 35; /// Resource deadlock would occur
36pub const ENAMETOOLONG = 36; /// File name too long
37pub const ENOLCK = 37; /// No record locks available
38pub const ENOSYS = 38; /// Function not implemented
39pub const ENOTEMPTY = 39; /// Directory not empty
40pub const ELOOP = 40; /// Too many symbolic links encountered
41pub const EWOULDBLOCK = EAGAIN; /// Operation would block
42pub const ENOMSG = 42; /// No message of desired type
43pub const EIDRM = 43; /// Identifier removed
44pub const ECHRNG = 44; /// Channel number out of range
45pub const EL2NSYNC = 45; /// Level 2 not synchronized
46pub const EL3HLT = 46; /// Level 3 halted
47pub const EL3RST = 47; /// Level 3 reset
48pub const ELNRNG = 48; /// Link number out of range
49pub const EUNATCH = 49; /// Protocol driver not attached
50pub const ENOCSI = 50; /// No CSI structure available
51pub const EL2HLT = 51; /// Level 2 halted
52pub const EBADE = 52; /// Invalid exchange
53pub const EBADR = 53; /// Invalid request descriptor
54pub const EXFULL = 54; /// Exchange full
55pub const ENOANO = 55; /// No anode
56pub const EBADRQC = 56; /// Invalid request code
57pub const EBADSLT = 57; /// Invalid slot
58
59pub const EBFONT = 59; /// Bad font file format
60pub const ENOSTR = 60; /// Device not a stream
61pub const ENODATA = 61; /// No data available
62pub const ETIME = 62; /// Timer expired
63pub const ENOSR = 63; /// Out of streams resources
64pub const ENONET = 64; /// Machine is not on the network
65pub const ENOPKG = 65; /// Package not installed
66pub const EREMOTE = 66; /// Object is remote
67pub const ENOLINK = 67; /// Link has been severed
68pub const EADV = 68; /// Advertise error
69pub const ESRMNT = 69; /// Srmount error
70pub const ECOMM = 70; /// Communication error on send
71pub const EPROTO = 71; /// Protocol error
72pub const EMULTIHOP = 72; /// Multihop attempted
73pub const EDOTDOT = 73; /// RFS specific error
74pub const EBADMSG = 74; /// Not a data message
75pub const EOVERFLOW = 75; /// Value too large for defined data type
76pub const ENOTUNIQ = 76; /// Name not unique on network
77pub const EBADFD = 77; /// File descriptor in bad state
78pub const EREMCHG = 78; /// Remote address changed
79pub const ELIBACC = 79; /// Can not access a needed shared library
80pub const ELIBBAD = 80; /// Accessing a corrupted shared library
81pub const ELIBSCN = 81; /// .lib section in a.out corrupted
82pub const ELIBMAX = 82; /// Attempting to link in too many shared libraries
83pub const ELIBEXEC = 83; /// Cannot exec a shared library directly
84pub const EILSEQ = 84; /// Illegal byte sequence
85pub const ERESTART = 85; /// Interrupted system call should be restarted
86pub const ESTRPIPE = 86; /// Streams pipe error
87pub const EUSERS = 87; /// Too many users
88pub const ENOTSOCK = 88; /// Socket operation on non-socket
89pub const EDESTADDRREQ = 89; /// Destination address required
90pub const EMSGSIZE = 90; /// Message too long
91pub const EPROTOTYPE = 91; /// Protocol wrong type for socket
92pub const ENOPROTOOPT = 92; /// Protocol not available
93pub const EPROTONOSUPPORT = 93; /// Protocol not supported
94pub const ESOCKTNOSUPPORT = 94; /// Socket type not supported
95pub const EOPNOTSUPP = 95; /// Operation not supported on transport endpoint
96pub const EPFNOSUPPORT = 96; /// Protocol family not supported
97pub const EAFNOSUPPORT = 97; /// Address family not supported by protocol
98pub const EADDRINUSE = 98; /// Address already in use
99pub const EADDRNOTAVAIL = 99; /// Cannot assign requested address
100pub const ENETDOWN = 100; /// Network is down
101pub const ENETUNREACH = 101; /// Network is unreachable
102pub const ENETRESET = 102; /// Network dropped connection because of reset
103pub const ECONNABORTED = 103; /// Software caused connection abort
104pub const ECONNRESET = 104; /// Connection reset by peer
105pub const ENOBUFS = 105; /// No buffer space available
106pub const EISCONN = 106; /// Transport endpoint is already connected
107pub const ENOTCONN = 107; /// Transport endpoint is not connected
108pub const ESHUTDOWN = 108; /// Cannot send after transport endpoint shutdown
109pub const ETOOMANYREFS = 109; /// Too many references: cannot splice
110pub const ETIMEDOUT = 110; /// Connection timed out
111pub const ECONNREFUSED = 111; /// Connection refused
112pub const EHOSTDOWN = 112; /// Host is down
113pub const EHOSTUNREACH = 113; /// No route to host
114pub const EALREADY = 114; /// Operation already in progress
115pub const EINPROGRESS = 115; /// Operation now in progress
116pub const ESTALE = 116; /// Stale NFS file handle
117pub const EUCLEAN = 117; /// Structure needs cleaning
118pub const ENOTNAM = 118; /// Not a XENIX named type file
119pub const ENAVAIL = 119; /// No XENIX semaphores available
120pub const EISNAM = 120; /// Is a named type file
121pub const EREMOTEIO = 121; /// Remote I/O error
122pub const EDQUOT = 122; /// Quota exceeded
123
124pub const ENOMEDIUM = 123; /// No medium found
125pub const EMEDIUMTYPE = 124; /// Wrong medium type
1/// Operation not permitted
2pub const EPERM = 1;
3
4/// No such file or directory
5pub const ENOENT = 2;
6
7/// No such process
8pub const ESRCH = 3;
9
10/// Interrupted system call
11pub const EINTR = 4;
12
13/// I/O error
14pub const EIO = 5;
15
16/// No such device or address
17pub const ENXIO = 6;
18
19/// Arg list too long
20pub const E2BIG = 7;
21
22/// Exec format error
23pub const ENOEXEC = 8;
24
25/// Bad file number
26pub const EBADF = 9;
27
28/// No child processes
29pub const ECHILD = 10;
30
31/// Try again
32pub const EAGAIN = 11;
33
34/// Out of memory
35pub const ENOMEM = 12;
36
37/// Permission denied
38pub const EACCES = 13;
39
40/// Bad address
41pub const EFAULT = 14;
42
43/// Block device required
44pub const ENOTBLK = 15;
45
46/// Device or resource busy
47pub const EBUSY = 16;
48
49/// File exists
50pub const EEXIST = 17;
51
52/// Cross-device link
53pub const EXDEV = 18;
54
55/// No such device
56pub const ENODEV = 19;
57
58/// Not a directory
59pub const ENOTDIR = 20;
60
61/// Is a directory
62pub const EISDIR = 21;
63
64/// Invalid argument
65pub const EINVAL = 22;
66
67/// File table overflow
68pub const ENFILE = 23;
69
70/// Too many open files
71pub const EMFILE = 24;
72
73/// Not a typewriter
74pub const ENOTTY = 25;
75
76/// Text file busy
77pub const ETXTBSY = 26;
78
79/// File too large
80pub const EFBIG = 27;
81
82/// No space left on device
83pub const ENOSPC = 28;
84
85/// Illegal seek
86pub const ESPIPE = 29;
87
88/// Read-only file system
89pub const EROFS = 30;
90
91/// Too many links
92pub const EMLINK = 31;
93
94/// Broken pipe
95pub const EPIPE = 32;
96
97/// Math argument out of domain of func
98pub const EDOM = 33;
99
100/// Math result not representable
101pub const ERANGE = 34;
102
103/// Resource deadlock would occur
104pub const EDEADLK = 35;
105
106/// File name too long
107pub const ENAMETOOLONG = 36;
108
109/// No record locks available
110pub const ENOLCK = 37;
111
112/// Function not implemented
113pub const ENOSYS = 38;
114
115/// Directory not empty
116pub const ENOTEMPTY = 39;
117
118/// Too many symbolic links encountered
119pub const ELOOP = 40;
120
121/// Operation would block
122pub const EWOULDBLOCK = EAGAIN;
123
124/// No message of desired type
125pub const ENOMSG = 42;
126
127/// Identifier removed
128pub const EIDRM = 43;
129
130/// Channel number out of range
131pub const ECHRNG = 44;
132
133/// Level 2 not synchronized
134pub const EL2NSYNC = 45;
135
136/// Level 3 halted
137pub const EL3HLT = 46;
138
139/// Level 3 reset
140pub const EL3RST = 47;
141
142/// Link number out of range
143pub const ELNRNG = 48;
144
145/// Protocol driver not attached
146pub const EUNATCH = 49;
147
148/// No CSI structure available
149pub const ENOCSI = 50;
150
151/// Level 2 halted
152pub const EL2HLT = 51;
153
154/// Invalid exchange
155pub const EBADE = 52;
156
157/// Invalid request descriptor
158pub const EBADR = 53;
159
160/// Exchange full
161pub const EXFULL = 54;
162
163/// No anode
164pub const ENOANO = 55;
165
166/// Invalid request code
167pub const EBADRQC = 56;
168
169/// Invalid slot
170pub const EBADSLT = 57;
171
172/// Bad font file format
173pub const EBFONT = 59;
174
175/// Device not a stream
176pub const ENOSTR = 60;
177
178/// No data available
179pub const ENODATA = 61;
180
181/// Timer expired
182pub const ETIME = 62;
183
184/// Out of streams resources
185pub const ENOSR = 63;
186
187/// Machine is not on the network
188pub const ENONET = 64;
189
190/// Package not installed
191pub const ENOPKG = 65;
192
193/// Object is remote
194pub const EREMOTE = 66;
195
196/// Link has been severed
197pub const ENOLINK = 67;
198
199/// Advertise error
200pub const EADV = 68;
201
202/// Srmount error
203pub const ESRMNT = 69;
204
205/// Communication error on send
206pub const ECOMM = 70;
207
208/// Protocol error
209pub const EPROTO = 71;
210
211/// Multihop attempted
212pub const EMULTIHOP = 72;
213
214/// RFS specific error
215pub const EDOTDOT = 73;
216
217/// Not a data message
218pub const EBADMSG = 74;
219
220/// Value too large for defined data type
221pub const EOVERFLOW = 75;
222
223/// Name not unique on network
224pub const ENOTUNIQ = 76;
225
226/// File descriptor in bad state
227pub const EBADFD = 77;
228
229/// Remote address changed
230pub const EREMCHG = 78;
231
232/// Can not access a needed shared library
233pub const ELIBACC = 79;
234
235/// Accessing a corrupted shared library
236pub const ELIBBAD = 80;
237
238/// .lib section in a.out corrupted
239pub const ELIBSCN = 81;
240
241/// Attempting to link in too many shared libraries
242pub const ELIBMAX = 82;
243
244/// Cannot exec a shared library directly
245pub const ELIBEXEC = 83;
246
247/// Illegal byte sequence
248pub const EILSEQ = 84;
249
250/// Interrupted system call should be restarted
251pub const ERESTART = 85;
252
253/// Streams pipe error
254pub const ESTRPIPE = 86;
255
256/// Too many users
257pub const EUSERS = 87;
258
259/// Socket operation on non-socket
260pub const ENOTSOCK = 88;
261
262/// Destination address required
263pub const EDESTADDRREQ = 89;
264
265/// Message too long
266pub const EMSGSIZE = 90;
267
268/// Protocol wrong type for socket
269pub const EPROTOTYPE = 91;
270
271/// Protocol not available
272pub const ENOPROTOOPT = 92;
273
274/// Protocol not supported
275pub const EPROTONOSUPPORT = 93;
276
277/// Socket type not supported
278pub const ESOCKTNOSUPPORT = 94;
279
280/// Operation not supported on transport endpoint
281pub const EOPNOTSUPP = 95;
282
283/// Protocol family not supported
284pub const EPFNOSUPPORT = 96;
285
286/// Address family not supported by protocol
287pub const EAFNOSUPPORT = 97;
288
289/// Address already in use
290pub const EADDRINUSE = 98;
291
292/// Cannot assign requested address
293pub const EADDRNOTAVAIL = 99;
294
295/// Network is down
296pub const ENETDOWN = 100;
297
298/// Network is unreachable
299pub const ENETUNREACH = 101;
300
301/// Network dropped connection because of reset
302pub const ENETRESET = 102;
303
304/// Software caused connection abort
305pub const ECONNABORTED = 103;
306
307/// Connection reset by peer
308pub const ECONNRESET = 104;
309
310/// No buffer space available
311pub const ENOBUFS = 105;
312
313/// Transport endpoint is already connected
314pub const EISCONN = 106;
315
316/// Transport endpoint is not connected
317pub const ENOTCONN = 107;
318
319/// Cannot send after transport endpoint shutdown
320pub const ESHUTDOWN = 108;
321
322/// Too many references: cannot splice
323pub const ETOOMANYREFS = 109;
324
325/// Connection timed out
326pub const ETIMEDOUT = 110;
327
328/// Connection refused
329pub const ECONNREFUSED = 111;
330
331/// Host is down
332pub const EHOSTDOWN = 112;
333
334/// No route to host
335pub const EHOSTUNREACH = 113;
336
337/// Operation already in progress
338pub const EALREADY = 114;
339
340/// Operation now in progress
341pub const EINPROGRESS = 115;
342
343/// Stale NFS file handle
344pub const ESTALE = 116;
345
346/// Structure needs cleaning
347pub const EUCLEAN = 117;
348
349/// Not a XENIX named type file
350pub const ENOTNAM = 118;
351
352/// No XENIX semaphores available
353pub const ENAVAIL = 119;
354
355/// Is a named type file
356pub const EISNAM = 120;
357
358/// Remote I/O error
359pub const EREMOTEIO = 121;
360
361/// Quota exceeded
362pub const EDQUOT = 122;
363
364/// No medium found
365pub const ENOMEDIUM = 123;
366
367/// Wrong medium type
368pub const EMEDIUMTYPE = 124;
126369
127370// nameserver query return codes
128pub const ENSROK = 0; /// DNS server returned answer with no data
129pub const ENSRNODATA = 160; /// DNS server returned answer with no data
130pub const ENSRFORMERR = 161; /// DNS server claims query was misformatted
131pub const ENSRSERVFAIL = 162; /// DNS server returned general failure
132pub const ENSRNOTFOUND = 163; /// Domain name not found
133pub const ENSRNOTIMP = 164; /// DNS server does not implement requested operation
134pub const ENSRREFUSED = 165; /// DNS server refused query
135pub const ENSRBADQUERY = 166; /// Misformatted DNS query
136pub const ENSRBADNAME = 167; /// Misformatted domain name
137pub const ENSRBADFAMILY = 168; /// Unsupported address family
138pub const ENSRBADRESP = 169; /// Misformatted DNS reply
139pub const ENSRCONNREFUSED = 170; /// Could not contact DNS servers
140pub const ENSRTIMEOUT = 171; /// Timeout while contacting DNS servers
141pub const ENSROF = 172; /// End of file
142pub const ENSRFILE = 173; /// Error reading file
143pub const ENSRNOMEM = 174; /// Out of memory
144pub const ENSRDESTRUCTION = 175; /// Application terminated lookup
145pub const ENSRQUERYDOMAINTOOLONG = 176; /// Domain name is too long
146pub const ENSRCNAMELOOP = 177; /// Domain name is too long
371
372/// DNS server returned answer with no data
373pub const ENSROK = 0;
374
375/// DNS server returned answer with no data
376pub const ENSRNODATA = 160;
377
378/// DNS server claims query was misformatted
379pub const ENSRFORMERR = 161;
380
381/// DNS server returned general failure
382pub const ENSRSERVFAIL = 162;
383
384/// Domain name not found
385pub const ENSRNOTFOUND = 163;
386
387/// DNS server does not implement requested operation
388pub const ENSRNOTIMP = 164;
389
390/// DNS server refused query
391pub const ENSRREFUSED = 165;
392
393/// Misformatted DNS query
394pub const ENSRBADQUERY = 166;
395
396/// Misformatted domain name
397pub const ENSRBADNAME = 167;
398
399/// Unsupported address family
400pub const ENSRBADFAMILY = 168;
401
402/// Misformatted DNS reply
403pub const ENSRBADRESP = 169;
404
405/// Could not contact DNS servers
406pub const ENSRCONNREFUSED = 170;
407
408/// Timeout while contacting DNS servers
409pub const ENSRTIMEOUT = 171;
410
411/// End of file
412pub const ENSROF = 172;
413
414/// Error reading file
415pub const ENSRFILE = 173;
416
417/// Out of memory
418pub const ENSRNOMEM = 174;
419
420/// Application terminated lookup
421pub const ENSRDESTRUCTION = 175;
422
423/// Domain name is too long
424pub const ENSRQUERYDOMAINTOOLONG = 176;
425
426/// Domain name is too long
427pub const ENSRCNAMELOOP = 177;
std/os/linux/index.zig+1-2
......@@ -823,8 +823,7 @@ pub fn clock_gettime(clk_id: i32, tp: &timespec) usize {
823823 if (@ptrToInt(f) != 0) {
824824 const rc = f(clk_id, tp);
825825 switch (rc) {
826 0,
827 @bitCast(usize, isize(-EINVAL)) => return rc,
826 0, @bitCast(usize, isize(-EINVAL)) => return rc,
828827 else => {},
829828 }
830829 }
std/os/linux/test.zig+6-6
......@@ -11,22 +11,22 @@ test "timer" {
1111 const timer_fd = linux.timerfd_create(linux.CLOCK_MONOTONIC, 0);
1212 assert(linux.getErrno(timer_fd) == 0);
1313
14 const time_interval = linux.timespec {
14 const time_interval = linux.timespec{
1515 .tv_sec = 0,
16 .tv_nsec = 2000000
16 .tv_nsec = 2000000,
1717 };
1818
19 const new_time = linux.itimerspec {
19 const new_time = linux.itimerspec{
2020 .it_interval = time_interval,
21 .it_value = time_interval
21 .it_value = time_interval,
2222 };
2323
2424 err = linux.timerfd_settime(i32(timer_fd), 0, &new_time, null);
2525 assert(err == 0);
2626
27 var event = linux.epoll_event {
27 var event = linux.epoll_event{
2828 .events = linux.EPOLLIN | linux.EPOLLOUT | linux.EPOLLET,
29 .data = linux.epoll_data { .ptr = 0 },
29 .data = linux.epoll_data{ .ptr = 0 },
3030 };
3131
3232 err = linux.epoll_ctl(i32(epoll_fd), linux.EPOLL_CTL_ADD, i32(timer_fd), &event);
std/os/linux/vdso.zig+11-9
......@@ -16,7 +16,10 @@ pub fn lookup(vername: []const u8, name: []const u8) usize {
1616 var base: usize = @maxValue(usize);
1717 {
1818 var i: usize = 0;
19 while (i < eh.e_phnum) : ({i += 1; ph_addr += eh.e_phentsize;}) {
19 while (i < eh.e_phnum) : ({
20 i += 1;
21 ph_addr += eh.e_phentsize;
22 }) {
2023 const this_ph = @intToPtr(&elf.Phdr, ph_addr);
2124 switch (this_ph.p_type) {
2225 elf.PT_LOAD => base = vdso_addr + this_ph.p_offset - this_ph.p_vaddr,
......@@ -54,15 +57,14 @@ pub fn lookup(vername: []const u8, name: []const u8) usize {
5457 const hashtab = maybe_hashtab ?? return 0;
5558 if (maybe_verdef == null) maybe_versym = null;
5659
57
58 const OK_TYPES = (1<<elf.STT_NOTYPE | 1<<elf.STT_OBJECT | 1<<elf.STT_FUNC | 1<<elf.STT_COMMON);
59 const OK_BINDS = (1<<elf.STB_GLOBAL | 1<<elf.STB_WEAK | 1<<elf.STB_GNU_UNIQUE);
60 const OK_TYPES = (1 << elf.STT_NOTYPE | 1 << elf.STT_OBJECT | 1 << elf.STT_FUNC | 1 << elf.STT_COMMON);
61 const OK_BINDS = (1 << elf.STB_GLOBAL | 1 << elf.STB_WEAK | 1 << elf.STB_GNU_UNIQUE);
6062
6163 var i: usize = 0;
6264 while (i < hashtab[1]) : (i += 1) {
63 if (0==(u32(1)<<u5(syms[i].st_info&0xf) & OK_TYPES)) continue;
64 if (0==(u32(1)<<u5(syms[i].st_info>>4) & OK_BINDS)) continue;
65 if (0==syms[i].st_shndx) continue;
65 if (0 == (u32(1) << u5(syms[i].st_info & 0xf) & OK_TYPES)) continue;
66 if (0 == (u32(1) << u5(syms[i].st_info >> 4) & OK_BINDS)) continue;
67 if (0 == syms[i].st_shndx) continue;
6668 if (!mem.eql(u8, name, cstr.toSliceConst(&strings[syms[i].st_name]))) continue;
6769 if (maybe_versym) |versym| {
6870 if (!checkver(??maybe_verdef, versym[i], vername, strings))
......@@ -78,12 +80,12 @@ fn checkver(def_arg: &elf.Verdef, vsym_arg: i32, vername: []const u8, strings: &
7880 var def = def_arg;
7981 const vsym = @bitCast(u32, vsym_arg) & 0x7fff;
8082 while (true) {
81 if (0==(def.vd_flags & elf.VER_FLG_BASE) and (def.vd_ndx & 0x7fff) == vsym)
83 if (0 == (def.vd_flags & elf.VER_FLG_BASE) and (def.vd_ndx & 0x7fff) == vsym)
8284 break;
8385 if (def.vd_next == 0)
8486 return false;
8587 def = @intToPtr(&elf.Verdef, @ptrToInt(def) + def.vd_next);
8688 }
87 const aux = @intToPtr(&elf.Verdaux, @ptrToInt(def ) + def.vd_aux);
89 const aux = @intToPtr(&elf.Verdaux, @ptrToInt(def) + def.vd_aux);
8890 return mem.eql(u8, vername, cstr.toSliceConst(&strings[aux.vda_name]));
8991}
std/os/linux/x86_64.zig+63-51
......@@ -330,26 +330,26 @@ pub const SYS_userfaultfd = 323;
330330pub const SYS_membarrier = 324;
331331pub const SYS_mlock2 = 325;
332332
333pub const O_CREAT = 0o100;
334pub const O_EXCL = 0o200;
335pub const O_NOCTTY = 0o400;
336pub const O_TRUNC = 0o1000;
337pub const O_APPEND = 0o2000;
338pub const O_NONBLOCK = 0o4000;
339pub const O_DSYNC = 0o10000;
340pub const O_SYNC = 0o4010000;
341pub const O_RSYNC = 0o4010000;
333pub const O_CREAT = 0o100;
334pub const O_EXCL = 0o200;
335pub const O_NOCTTY = 0o400;
336pub const O_TRUNC = 0o1000;
337pub const O_APPEND = 0o2000;
338pub const O_NONBLOCK = 0o4000;
339pub const O_DSYNC = 0o10000;
340pub const O_SYNC = 0o4010000;
341pub const O_RSYNC = 0o4010000;
342342pub const O_DIRECTORY = 0o200000;
343pub const O_NOFOLLOW = 0o400000;
344pub const O_CLOEXEC = 0o2000000;
343pub const O_NOFOLLOW = 0o400000;
344pub const O_CLOEXEC = 0o2000000;
345345
346pub const O_ASYNC = 0o20000;
347pub const O_DIRECT = 0o40000;
348pub const O_LARGEFILE = 0;
349pub const O_NOATIME = 0o1000000;
350pub const O_PATH = 0o10000000;
346pub const O_ASYNC = 0o20000;
347pub const O_DIRECT = 0o40000;
348pub const O_LARGEFILE = 0;
349pub const O_NOATIME = 0o1000000;
350pub const O_PATH = 0o10000000;
351351pub const O_TMPFILE = 0o20200000;
352pub const O_NDELAY = O_NONBLOCK;
352pub const O_NDELAY = O_NONBLOCK;
353353
354354pub const F_DUPFD = 0;
355355pub const F_GETFD = 1;
......@@ -371,7 +371,6 @@ pub const F_GETOWN_EX = 16;
371371
372372pub const F_GETOWNER_UIDS = 17;
373373
374
375374pub const VDSO_USEFUL = true;
376375pub const VDSO_CGT_SYM = "__vdso_clock_gettime";
377376pub const VDSO_CGT_VER = "LINUX_2.6";
......@@ -382,72 +381,85 @@ pub fn syscall0(number: usize) usize {
382381 return asm volatile ("syscall"
383382 : [ret] "={rax}" (-> usize)
384383 : [number] "{rax}" (number)
385 : "rcx", "r11");
384 : "rcx", "r11"
385 );
386386}
387387
388388pub fn syscall1(number: usize, arg1: usize) usize {
389389 return asm volatile ("syscall"
390390 : [ret] "={rax}" (-> usize)
391391 : [number] "{rax}" (number),
392 [arg1] "{rdi}" (arg1)
393 : "rcx", "r11");
392 [arg1] "{rdi}" (arg1)
393 : "rcx", "r11"
394 );
394395}
395396
396397pub fn syscall2(number: usize, arg1: usize, arg2: usize) usize {
397398 return asm volatile ("syscall"
398399 : [ret] "={rax}" (-> usize)
399400 : [number] "{rax}" (number),
400 [arg1] "{rdi}" (arg1),
401 [arg2] "{rsi}" (arg2)
402 : "rcx", "r11");
401 [arg1] "{rdi}" (arg1),
402 [arg2] "{rsi}" (arg2)
403 : "rcx", "r11"
404 );
403405}
404406
405407pub fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) usize {
406408 return asm volatile ("syscall"
407409 : [ret] "={rax}" (-> usize)
408410 : [number] "{rax}" (number),
409 [arg1] "{rdi}" (arg1),
410 [arg2] "{rsi}" (arg2),
411 [arg3] "{rdx}" (arg3)
412 : "rcx", "r11");
411 [arg1] "{rdi}" (arg1),
412 [arg2] "{rsi}" (arg2),
413 [arg3] "{rdx}" (arg3)
414 : "rcx", "r11"
415 );
413416}
414417
415418pub fn syscall4(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
416419 return asm volatile ("syscall"
417420 : [ret] "={rax}" (-> usize)
418421 : [number] "{rax}" (number),
419 [arg1] "{rdi}" (arg1),
420 [arg2] "{rsi}" (arg2),
421 [arg3] "{rdx}" (arg3),
422 [arg4] "{r10}" (arg4)
423 : "rcx", "r11");
422 [arg1] "{rdi}" (arg1),
423 [arg2] "{rsi}" (arg2),
424 [arg3] "{rdx}" (arg3),
425 [arg4] "{r10}" (arg4)
426 : "rcx", "r11"
427 );
424428}
425429
426430pub fn syscall5(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
427431 return asm volatile ("syscall"
428432 : [ret] "={rax}" (-> usize)
429433 : [number] "{rax}" (number),
430 [arg1] "{rdi}" (arg1),
431 [arg2] "{rsi}" (arg2),
432 [arg3] "{rdx}" (arg3),
433 [arg4] "{r10}" (arg4),
434 [arg5] "{r8}" (arg5)
435 : "rcx", "r11");
434 [arg1] "{rdi}" (arg1),
435 [arg2] "{rsi}" (arg2),
436 [arg3] "{rdx}" (arg3),
437 [arg4] "{r10}" (arg4),
438 [arg5] "{r8}" (arg5)
439 : "rcx", "r11"
440 );
436441}
437442
438pub fn syscall6(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
439 arg5: usize, arg6: usize) usize
440{
443pub fn syscall6(
444 number: usize,
445 arg1: usize,
446 arg2: usize,
447 arg3: usize,
448 arg4: usize,
449 arg5: usize,
450 arg6: usize,
451) usize {
441452 return asm volatile ("syscall"
442453 : [ret] "={rax}" (-> usize)
443454 : [number] "{rax}" (number),
444 [arg1] "{rdi}" (arg1),
445 [arg2] "{rsi}" (arg2),
446 [arg3] "{rdx}" (arg3),
447 [arg4] "{r10}" (arg4),
448 [arg5] "{r8}" (arg5),
449 [arg6] "{r9}" (arg6)
450 : "rcx", "r11");
455 [arg1] "{rdi}" (arg1),
456 [arg2] "{rsi}" (arg2),
457 [arg3] "{rdx}" (arg3),
458 [arg4] "{r10}" (arg4),
459 [arg5] "{r8}" (arg5),
460 [arg6] "{r9}" (arg6)
461 : "rcx", "r11"
462 );
451463}
452464
453465/// This matches the libc clone function.
......@@ -457,10 +469,10 @@ pub nakedcc fn restore_rt() void {
457469 return asm volatile ("syscall"
458470 :
459471 : [number] "{rax}" (usize(SYS_rt_sigreturn))
460 : "rcx", "r11");
472 : "rcx", "r11"
473 );
461474}
462475
463
464476pub const msghdr = extern struct {
465477 msg_name: &u8,
466478 msg_namelen: socklen_t,
std/os/path.zig+41-52
......@@ -55,9 +55,7 @@ test "os.path.join" {
5555 assert(mem.eql(u8, try joinWindows(debug.global_allocator, "c:\\", "a", "b\\", "c"), "c:\\a\\b\\c"));
5656 assert(mem.eql(u8, try joinWindows(debug.global_allocator, "c:\\a\\", "b\\", "c"), "c:\\a\\b\\c"));
5757
58 assert(mem.eql(u8, try joinWindows(debug.global_allocator,
59 "c:\\home\\andy\\dev\\zig\\build\\lib\\zig\\std", "io.zig"),
60 "c:\\home\\andy\\dev\\zig\\build\\lib\\zig\\std\\io.zig"));
58 assert(mem.eql(u8, try joinWindows(debug.global_allocator, "c:\\home\\andy\\dev\\zig\\build\\lib\\zig\\std", "io.zig"), "c:\\home\\andy\\dev\\zig\\build\\lib\\zig\\std\\io.zig"));
6159
6260 assert(mem.eql(u8, try joinPosix(debug.global_allocator, "/a/b", "c"), "/a/b/c"));
6361 assert(mem.eql(u8, try joinPosix(debug.global_allocator, "/a/b/", "c"), "/a/b/c"));
......@@ -65,8 +63,7 @@ test "os.path.join" {
6563 assert(mem.eql(u8, try joinPosix(debug.global_allocator, "/", "a", "b/", "c"), "/a/b/c"));
6664 assert(mem.eql(u8, try joinPosix(debug.global_allocator, "/a/", "b/", "c"), "/a/b/c"));
6765
68 assert(mem.eql(u8, try joinPosix(debug.global_allocator, "/home/andy/dev/zig/build/lib/zig/std", "io.zig"),
69 "/home/andy/dev/zig/build/lib/zig/std/io.zig"));
66 assert(mem.eql(u8, try joinPosix(debug.global_allocator, "/home/andy/dev/zig/build/lib/zig/std", "io.zig"), "/home/andy/dev/zig/build/lib/zig/std/io.zig"));
7067}
7168
7269pub fn isAbsolute(path: []const u8) bool {
......@@ -151,22 +148,22 @@ pub const WindowsPath = struct {
151148
152149pub fn windowsParsePath(path: []const u8) WindowsPath {
153150 if (path.len >= 2 and path[1] == ':') {
154 return WindowsPath {
151 return WindowsPath{
155152 .is_abs = isAbsoluteWindows(path),
156153 .kind = WindowsPath.Kind.Drive,
157154 .disk_designator = path[0..2],
158155 };
159156 }
160157 if (path.len >= 1 and (path[0] == '/' or path[0] == '\\') and
161 (path.len == 1 or (path[1] != '/' and path[1] != '\\')))
158 (path.len == 1 or (path[1] != '/' and path[1] != '\\')))
162159 {
163 return WindowsPath {
160 return WindowsPath{
164161 .is_abs = true,
165162 .kind = WindowsPath.Kind.None,
166163 .disk_designator = path[0..0],
167164 };
168165 }
169 const relative_path = WindowsPath {
166 const relative_path = WindowsPath{
170167 .kind = WindowsPath.Kind.None,
171168 .disk_designator = []u8{},
172169 .is_abs = false,
......@@ -178,7 +175,7 @@ pub fn windowsParsePath(path: []const u8) WindowsPath {
178175 // TODO when I combined these together with `inline for` the compiler crashed
179176 {
180177 const this_sep = '/';
181 const two_sep = []u8{this_sep, this_sep};
178 const two_sep = []u8{ this_sep, this_sep };
182179 if (mem.startsWith(u8, path, two_sep)) {
183180 if (path[2] == this_sep) {
184181 return relative_path;
......@@ -187,7 +184,7 @@ pub fn windowsParsePath(path: []const u8) WindowsPath {
187184 var it = mem.split(path, []u8{this_sep});
188185 _ = (it.next() ?? return relative_path);
189186 _ = (it.next() ?? return relative_path);
190 return WindowsPath {
187 return WindowsPath{
191188 .is_abs = isAbsoluteWindows(path),
192189 .kind = WindowsPath.Kind.NetworkShare,
193190 .disk_designator = path[0..it.index],
......@@ -196,7 +193,7 @@ pub fn windowsParsePath(path: []const u8) WindowsPath {
196193 }
197194 {
198195 const this_sep = '\\';
199 const two_sep = []u8{this_sep, this_sep};
196 const two_sep = []u8{ this_sep, this_sep };
200197 if (mem.startsWith(u8, path, two_sep)) {
201198 if (path[2] == this_sep) {
202199 return relative_path;
......@@ -205,7 +202,7 @@ pub fn windowsParsePath(path: []const u8) WindowsPath {
205202 var it = mem.split(path, []u8{this_sep});
206203 _ = (it.next() ?? return relative_path);
207204 _ = (it.next() ?? return relative_path);
208 return WindowsPath {
205 return WindowsPath{
209206 .is_abs = isAbsoluteWindows(path),
210207 .kind = WindowsPath.Kind.NetworkShare,
211208 .disk_designator = path[0..it.index],
......@@ -296,7 +293,7 @@ fn compareDiskDesignators(kind: WindowsPath.Kind, p1: []const u8, p2: []const u8
296293
297294fn asciiUpper(byte: u8) u8 {
298295 return switch (byte) {
299 'a' ... 'z' => 'A' + (byte - 'a'),
296 'a'...'z' => 'A' + (byte - 'a'),
300297 else => byte,
301298 };
302299}
......@@ -372,7 +369,6 @@ pub fn resolveWindows(allocator: &Allocator, paths: []const []const u8) ![]u8 {
372369 max_size += p.len + 1;
373370 }
374371
375
376372 // if we will result with a disk designator, loop again to determine
377373 // which is the last time the disk designator is absolutely specified, if any
378374 // and count up the max bytes for paths related to this disk designator
......@@ -386,8 +382,7 @@ pub fn resolveWindows(allocator: &Allocator, paths: []const []const u8) ![]u8 {
386382 const parsed = windowsParsePath(p);
387383 if (parsed.kind != WindowsPath.Kind.None) {
388384 if (parsed.kind == have_drive_kind) {
389 correct_disk_designator = compareDiskDesignators(have_drive_kind,
390 result_disk_designator, parsed.disk_designator);
385 correct_disk_designator = compareDiskDesignators(have_drive_kind, result_disk_designator, parsed.disk_designator);
391386 } else {
392387 continue;
393388 }
......@@ -404,7 +399,6 @@ pub fn resolveWindows(allocator: &Allocator, paths: []const []const u8) ![]u8 {
404399 }
405400 }
406401
407
408402 // Allocate result and fill in the disk designator, calling getCwd if we have to.
409403 var result: []u8 = undefined;
410404 var result_index: usize = 0;
......@@ -433,7 +427,7 @@ pub fn resolveWindows(allocator: &Allocator, paths: []const []const u8) ![]u8 {
433427 result_index += 1;
434428 mem.copy(u8, result[result_index..], other_name);
435429 result_index += other_name.len;
436
430
437431 result_disk_designator = result[0..result_index];
438432 },
439433 WindowsPath.Kind.None => {
......@@ -478,8 +472,7 @@ pub fn resolveWindows(allocator: &Allocator, paths: []const []const u8) ![]u8 {
478472
479473 if (parsed.kind != WindowsPath.Kind.None) {
480474 if (parsed.kind == have_drive_kind) {
481 correct_disk_designator = compareDiskDesignators(have_drive_kind,
482 result_disk_designator, parsed.disk_designator);
475 correct_disk_designator = compareDiskDesignators(have_drive_kind, result_disk_designator, parsed.disk_designator);
483476 } else {
484477 continue;
485478 }
......@@ -591,7 +584,7 @@ test "os.path.resolve" {
591584 }
592585 assert(mem.eql(u8, testResolveWindows([][]const u8{"."}), cwd));
593586 } else {
594 assert(mem.eql(u8, testResolvePosix([][]const u8{"a/b/c/", "../../.."}), cwd));
587 assert(mem.eql(u8, testResolvePosix([][]const u8{ "a/b/c/", "../../.." }), cwd));
595588 assert(mem.eql(u8, testResolvePosix([][]const u8{"."}), cwd));
596589 }
597590}
......@@ -601,16 +594,15 @@ test "os.path.resolveWindows" {
601594 const cwd = try os.getCwd(debug.global_allocator);
602595 const parsed_cwd = windowsParsePath(cwd);
603596 {
604 const result = testResolveWindows([][]const u8{"/usr/local", "lib\\zig\\std\\array_list.zig"});
605 const expected = try join(debug.global_allocator,
606 parsed_cwd.disk_designator, "usr\\local\\lib\\zig\\std\\array_list.zig");
597 const result = testResolveWindows([][]const u8{ "/usr/local", "lib\\zig\\std\\array_list.zig" });
598 const expected = try join(debug.global_allocator, parsed_cwd.disk_designator, "usr\\local\\lib\\zig\\std\\array_list.zig");
607599 if (parsed_cwd.kind == WindowsPath.Kind.Drive) {
608600 expected[0] = asciiUpper(parsed_cwd.disk_designator[0]);
609601 }
610602 assert(mem.eql(u8, result, expected));
611603 }
612604 {
613 const result = testResolveWindows([][]const u8{"usr/local", "lib\\zig"});
605 const result = testResolveWindows([][]const u8{ "usr/local", "lib\\zig" });
614606 const expected = try join(debug.global_allocator, cwd, "usr\\local\\lib\\zig");
615607 if (parsed_cwd.kind == WindowsPath.Kind.Drive) {
616608 expected[0] = asciiUpper(parsed_cwd.disk_designator[0]);
......@@ -619,33 +611,32 @@ test "os.path.resolveWindows" {
619611 }
620612 }
621613
622 assert(mem.eql(u8, testResolveWindows([][]const u8{"c:\\a\\b\\c", "/hi", "ok"}), "C:\\hi\\ok"));
623 assert(mem.eql(u8, testResolveWindows([][]const u8{"c:/blah\\blah", "d:/games", "c:../a"}), "C:\\blah\\a"));
624 assert(mem.eql(u8, testResolveWindows([][]const u8{"c:/blah\\blah", "d:/games", "C:../a"}), "C:\\blah\\a"));
625 assert(mem.eql(u8, testResolveWindows([][]const u8{"c:/ignore", "d:\\a/b\\c/d", "\\e.exe"}), "D:\\e.exe"));
626 assert(mem.eql(u8, testResolveWindows([][]const u8{"c:/ignore", "c:/some/file"}), "C:\\some\\file"));
627 assert(mem.eql(u8, testResolveWindows([][]const u8{"d:/ignore", "d:some/dir//"}), "D:\\ignore\\some\\dir"));
628 assert(mem.eql(u8, testResolveWindows([][]const u8{"//server/share", "..", "relative\\"}), "\\\\server\\share\\relative"));
629 assert(mem.eql(u8, testResolveWindows([][]const u8{"c:/", "//"}), "C:\\"));
630 assert(mem.eql(u8, testResolveWindows([][]const u8{"c:/", "//dir"}), "C:\\dir"));
631 assert(mem.eql(u8, testResolveWindows([][]const u8{"c:/", "//server/share"}), "\\\\server\\share\\"));
632 assert(mem.eql(u8, testResolveWindows([][]const u8{"c:/", "//server//share"}), "\\\\server\\share\\"));
633 assert(mem.eql(u8, testResolveWindows([][]const u8{"c:/", "///some//dir"}), "C:\\some\\dir"));
634 assert(mem.eql(u8, testResolveWindows([][]const u8{"C:\\foo\\tmp.3\\", "..\\tmp.3\\cycles\\root.js"}),
635 "C:\\foo\\tmp.3\\cycles\\root.js"));
614 assert(mem.eql(u8, testResolveWindows([][]const u8{ "c:\\a\\b\\c", "/hi", "ok" }), "C:\\hi\\ok"));
615 assert(mem.eql(u8, testResolveWindows([][]const u8{ "c:/blah\\blah", "d:/games", "c:../a" }), "C:\\blah\\a"));
616 assert(mem.eql(u8, testResolveWindows([][]const u8{ "c:/blah\\blah", "d:/games", "C:../a" }), "C:\\blah\\a"));
617 assert(mem.eql(u8, testResolveWindows([][]const u8{ "c:/ignore", "d:\\a/b\\c/d", "\\e.exe" }), "D:\\e.exe"));
618 assert(mem.eql(u8, testResolveWindows([][]const u8{ "c:/ignore", "c:/some/file" }), "C:\\some\\file"));
619 assert(mem.eql(u8, testResolveWindows([][]const u8{ "d:/ignore", "d:some/dir//" }), "D:\\ignore\\some\\dir"));
620 assert(mem.eql(u8, testResolveWindows([][]const u8{ "//server/share", "..", "relative\\" }), "\\\\server\\share\\relative"));
621 assert(mem.eql(u8, testResolveWindows([][]const u8{ "c:/", "//" }), "C:\\"));
622 assert(mem.eql(u8, testResolveWindows([][]const u8{ "c:/", "//dir" }), "C:\\dir"));
623 assert(mem.eql(u8, testResolveWindows([][]const u8{ "c:/", "//server/share" }), "\\\\server\\share\\"));
624 assert(mem.eql(u8, testResolveWindows([][]const u8{ "c:/", "//server//share" }), "\\\\server\\share\\"));
625 assert(mem.eql(u8, testResolveWindows([][]const u8{ "c:/", "///some//dir" }), "C:\\some\\dir"));
626 assert(mem.eql(u8, testResolveWindows([][]const u8{ "C:\\foo\\tmp.3\\", "..\\tmp.3\\cycles\\root.js" }), "C:\\foo\\tmp.3\\cycles\\root.js"));
636627}
637628
638629test "os.path.resolvePosix" {
639 assert(mem.eql(u8, testResolvePosix([][]const u8{"/a/b", "c"}), "/a/b/c"));
640 assert(mem.eql(u8, testResolvePosix([][]const u8{"/a/b", "c", "//d", "e///"}), "/d/e"));
641 assert(mem.eql(u8, testResolvePosix([][]const u8{"/a/b/c", "..", "../"}), "/a"));
642 assert(mem.eql(u8, testResolvePosix([][]const u8{"/", "..", ".."}), "/"));
630 assert(mem.eql(u8, testResolvePosix([][]const u8{ "/a/b", "c" }), "/a/b/c"));
631 assert(mem.eql(u8, testResolvePosix([][]const u8{ "/a/b", "c", "//d", "e///" }), "/d/e"));
632 assert(mem.eql(u8, testResolvePosix([][]const u8{ "/a/b/c", "..", "../" }), "/a"));
633 assert(mem.eql(u8, testResolvePosix([][]const u8{ "/", "..", ".." }), "/"));
643634 assert(mem.eql(u8, testResolvePosix([][]const u8{"/a/b/c/"}), "/a/b/c"));
644635
645 assert(mem.eql(u8, testResolvePosix([][]const u8{"/var/lib", "../", "file/"}), "/var/file"));
646 assert(mem.eql(u8, testResolvePosix([][]const u8{"/var/lib", "/../", "file/"}), "/file"));
647 assert(mem.eql(u8, testResolvePosix([][]const u8{"/some/dir", ".", "/absolute/"}), "/absolute"));
648 assert(mem.eql(u8, testResolvePosix([][]const u8{"/foo/tmp.3/", "../tmp.3/cycles/root.js"}), "/foo/tmp.3/cycles/root.js"));
636 assert(mem.eql(u8, testResolvePosix([][]const u8{ "/var/lib", "../", "file/" }), "/var/file"));
637 assert(mem.eql(u8, testResolvePosix([][]const u8{ "/var/lib", "/../", "file/" }), "/file"));
638 assert(mem.eql(u8, testResolvePosix([][]const u8{ "/some/dir", ".", "/absolute/" }), "/absolute"));
639 assert(mem.eql(u8, testResolvePosix([][]const u8{ "/foo/tmp.3/", "../tmp.3/cycles/root.js" }), "/foo/tmp.3/cycles/root.js"));
649640}
650641
651642fn testResolveWindows(paths: []const []const u8) []u8 {
......@@ -1079,9 +1070,7 @@ pub fn real(allocator: &Allocator, pathname: []const u8) ![]u8 {
10791070 mem.copy(u8, pathname_buf, pathname);
10801071 pathname_buf[pathname.len] = 0;
10811072
1082 const h_file = windows.CreateFileA(pathname_buf.ptr,
1083 windows.GENERIC_READ, windows.FILE_SHARE_READ, null, windows.OPEN_EXISTING,
1084 windows.FILE_ATTRIBUTE_NORMAL, null);
1073 const h_file = windows.CreateFileA(pathname_buf.ptr, windows.GENERIC_READ, windows.FILE_SHARE_READ, null, windows.OPEN_EXISTING, windows.FILE_ATTRIBUTE_NORMAL, null);
10851074 if (h_file == windows.INVALID_HANDLE_VALUE) {
10861075 const err = windows.GetLastError();
10871076 return switch (err) {
......@@ -1161,7 +1150,7 @@ pub fn real(allocator: &Allocator, pathname: []const u8) ![]u8 {
11611150 return allocator.shrink(u8, result_buf, cstr.len(result_buf.ptr));
11621151 },
11631152 Os.linux => {
1164 const fd = try os.posixOpen(allocator, pathname, posix.O_PATH|posix.O_NONBLOCK|posix.O_CLOEXEC, 0);
1153 const fd = try os.posixOpen(allocator, pathname, posix.O_PATH | posix.O_NONBLOCK | posix.O_CLOEXEC, 0);
11651154 defer os.close(fd);
11661155
11671156 var buf: ["/proc/self/fd/-2147483648".len]u8 = undefined;
std/os/time.zig+31-38
......@@ -27,7 +27,7 @@ pub fn sleep(seconds: usize, nanoseconds: usize) void {
2727
2828const u63 = @IntType(false, 63);
2929pub fn posixSleep(seconds: u63, nanoseconds: u63) void {
30 var req = posix.timespec {
30 var req = posix.timespec{
3131 .tv_sec = seconds,
3232 .tv_nsec = nanoseconds,
3333 };
......@@ -71,7 +71,7 @@ fn milliTimestampWindows() u64 {
7171 var ft: i64 = undefined;
7272 windows.GetSystemTimeAsFileTime(&ft);
7373 const hns_per_ms = (ns_per_s / 100) / ms_per_s;
74 const epoch_adj = epoch.windows * ms_per_s;
74 const epoch_adj = epoch.windows * ms_per_s;
7575 return u64(@divFloor(ft, hns_per_ms) + epoch_adj);
7676}
7777
......@@ -83,7 +83,7 @@ fn milliTimestampDarwin() u64 {
8383 debug.assert(err == 0);
8484 const sec_ms = u64(tv.tv_sec) * ms_per_s;
8585 const usec_ms = @divFloor(u64(tv.tv_usec), us_per_s / ms_per_s);
86 return u64(sec_ms) + u64(usec_ms);
86 return u64(sec_ms) + u64(usec_ms);
8787}
8888
8989fn milliTimestampPosix() u64 {
......@@ -110,17 +110,16 @@ pub const s_per_hour = s_per_min * 60;
110110pub const s_per_day = s_per_hour * 24;
111111pub const s_per_week = s_per_day * 7;
112112
113
114113/// A monotonic high-performance timer.
115114/// Timer.start() must be called to initialize the struct, which captures
116115/// the counter frequency on windows and darwin, records the resolution,
117116/// and gives the user an oportunity to check for the existnece of
118117/// monotonic clocks without forcing them to check for error on each read.
119/// .resolution is in nanoseconds on all platforms but .start_time's meaning
120/// depends on the OS. On Windows and Darwin it is a hardware counter
118/// .resolution is in nanoseconds on all platforms but .start_time's meaning
119/// depends on the OS. On Windows and Darwin it is a hardware counter
121120/// value that requires calculation to convert to a meaninful unit.
122121pub const Timer = struct {
123
122
124123 //if we used resolution's value when performing the
125124 // performance counter calc on windows/darwin, it would
126125 // be less precise
......@@ -131,10 +130,9 @@ pub const Timer = struct {
131130 },
132131 resolution: u64,
133132 start_time: u64,
134
135
133
136134 //At some point we may change our minds on RAW, but for now we're
137 // sticking with posix standard MONOTONIC. For more information, see:
135 // sticking with posix standard MONOTONIC. For more information, see:
138136 // https://github.com/ziglang/zig/pull/933
139137 //
140138 //const monotonic_clock_id = switch(builtin.os) {
......@@ -142,20 +140,21 @@ pub const Timer = struct {
142140 // else => posix.CLOCK_MONOTONIC,
143141 //};
144142 const monotonic_clock_id = posix.CLOCK_MONOTONIC;
145
146
147143 /// Initialize the timer structure.
148144 //This gives us an oportunity to grab the counter frequency in windows.
149145 //On Windows: QueryPerformanceCounter will succeed on anything >= XP/2000.
150 //On Posix: CLOCK_MONOTONIC will only fail if the monotonic counter is not
151 // supported, or if the timespec pointer is out of bounds, which should be
146 //On Posix: CLOCK_MONOTONIC will only fail if the monotonic counter is not
147 // supported, or if the timespec pointer is out of bounds, which should be
152148 // impossible here barring cosmic rays or other such occurances of
153149 // incredibly bad luck.
154150 //On Darwin: This cannot fail, as far as I am able to tell.
155 const TimerError = error{TimerUnsupported, Unexpected};
151 const TimerError = error{
152 TimerUnsupported,
153 Unexpected,
154 };
156155 pub fn start() TimerError!Timer {
157156 var self: Timer = undefined;
158
157
159158 switch (builtin.os) {
160159 Os.windows => {
161160 var freq: i64 = undefined;
......@@ -163,7 +162,7 @@ pub const Timer = struct {
163162 if (err == windows.FALSE) return error.TimerUnsupported;
164163 self.frequency = u64(freq);
165164 self.resolution = @divFloor(ns_per_s, self.frequency);
166
165
167166 var start_time: i64 = undefined;
168167 err = windows.QueryPerformanceCounter(&start_time);
169168 debug.assert(err != windows.FALSE);
......@@ -171,9 +170,9 @@ pub const Timer = struct {
171170 },
172171 Os.linux => {
173172 //On Linux, seccomp can do arbitrary things to our ability to call
174 // syscalls, including return any errno value it wants and
173 // syscalls, including return any errno value it wants and
175174 // inconsistently throwing errors. Since we can't account for
176 // abuses of seccomp in a reasonable way, we'll assume that if
175 // abuses of seccomp in a reasonable way, we'll assume that if
177176 // seccomp is going to block us it will at least do so consistently
178177 var ts: posix.timespec = undefined;
179178 var result = posix.clock_getres(monotonic_clock_id, &ts);
......@@ -184,7 +183,7 @@ pub const Timer = struct {
184183 else => return std.os.unexpectedErrorPosix(errno),
185184 }
186185 self.resolution = u64(ts.tv_sec) * u64(ns_per_s) + u64(ts.tv_nsec);
187
186
188187 result = posix.clock_gettime(monotonic_clock_id, &ts);
189188 errno = posix.getErrno(result);
190189 if (errno != 0) return std.os.unexpectedErrorPosix(errno);
......@@ -199,7 +198,7 @@ pub const Timer = struct {
199198 }
200199 return self;
201200 }
202
201
203202 /// Reads the timer value since start or the last reset in nanoseconds
204203 pub fn read(self: &Timer) u64 {
205204 var clock = clockNative() - self.start_time;
......@@ -210,13 +209,12 @@ pub const Timer = struct {
210209 else => @compileError("Unsupported OS"),
211210 };
212211 }
213
212
214213 /// Resets the timer value to 0/now.
215 pub fn reset(self: &Timer) void
216 {
214 pub fn reset(self: &Timer) void {
217215 self.start_time = clockNative();
218216 }
219
217
220218 /// Returns the current value of the timer in nanoseconds, then resets it
221219 pub fn lap(self: &Timer) u64 {
222220 var now = clockNative();
......@@ -224,26 +222,25 @@ pub const Timer = struct {
224222 self.start_time = now;
225223 return lap_time;
226224 }
227
228
225
229226 const clockNative = switch (builtin.os) {
230227 Os.windows => clockWindows,
231228 Os.linux => clockLinux,
232229 Os.macosx, Os.ios => clockDarwin,
233230 else => @compileError("Unsupported OS"),
234231 };
235
232
236233 fn clockWindows() u64 {
237234 var result: i64 = undefined;
238235 var err = windows.QueryPerformanceCounter(&result);
239236 debug.assert(err != windows.FALSE);
240237 return u64(result);
241238 }
242
239
243240 fn clockDarwin() u64 {
244241 return darwin.mach_absolute_time();
245242 }
246
243
247244 fn clockLinux() u64 {
248245 var ts: posix.timespec = undefined;
249246 var result = posix.clock_gettime(monotonic_clock_id, &ts);
......@@ -252,10 +249,6 @@ pub const Timer = struct {
252249 }
253250};
254251
255
256
257
258
259252test "os.time.sleep" {
260253 sleep(0, 1);
261254}
......@@ -263,7 +256,7 @@ test "os.time.sleep" {
263256test "os.time.timestamp" {
264257 const ns_per_ms = (ns_per_s / ms_per_s);
265258 const margin = 50;
266
259
267260 const time_0 = milliTimestamp();
268261 sleep(0, ns_per_ms);
269262 const time_1 = milliTimestamp();
......@@ -274,15 +267,15 @@ test "os.time.timestamp" {
274267test "os.time.Timer" {
275268 const ns_per_ms = (ns_per_s / ms_per_s);
276269 const margin = ns_per_ms * 50;
277
270
278271 var timer = try Timer.start();
279272 sleep(0, 10 * ns_per_ms);
280273 const time_0 = timer.read();
281274 debug.assert(time_0 > 0 and time_0 < margin);
282
275
283276 const time_1 = timer.lap();
284277 debug.assert(time_1 >= time_0);
285
278
286279 timer.reset();
287280 debug.assert(timer.read() < time_1);
288281}
std/os/windows/error.zig+1188
......@@ -1,2379 +1,3567 @@
11/// The operation completed successfully.
22pub const SUCCESS = 0;
3
34/// Incorrect function.
45pub const INVALID_FUNCTION = 1;
6
57/// The system cannot find the file specified.
68pub const FILE_NOT_FOUND = 2;
9
710/// The system cannot find the path specified.
811pub const PATH_NOT_FOUND = 3;
12
913/// The system cannot open the file.
1014pub const TOO_MANY_OPEN_FILES = 4;
15
1116/// Access is denied.
1217pub const ACCESS_DENIED = 5;
18
1319/// The handle is invalid.
1420pub const INVALID_HANDLE = 6;
21
1522/// The storage control blocks were destroyed.
1623pub const ARENA_TRASHED = 7;
24
1725/// Not enough storage is available to process this command.
1826pub const NOT_ENOUGH_MEMORY = 8;
27
1928/// The storage control block address is invalid.
2029pub const INVALID_BLOCK = 9;
30
2131/// The environment is incorrect.
2232pub const BAD_ENVIRONMENT = 10;
33
2334/// An attempt was made to load a program with an incorrect format.
2435pub const BAD_FORMAT = 11;
36
2537/// The access code is invalid.
2638pub const INVALID_ACCESS = 12;
39
2740/// The data is invalid.
2841pub const INVALID_DATA = 13;
42
2943/// Not enough storage is available to complete this operation.
3044pub const OUTOFMEMORY = 14;
45
3146/// The system cannot find the drive specified.
3247pub const INVALID_DRIVE = 15;
48
3349/// The directory cannot be removed.
3450pub const CURRENT_DIRECTORY = 16;
51
3552/// The system cannot move the file to a different disk drive.
3653pub const NOT_SAME_DEVICE = 17;
54
3755/// There are no more files.
3856pub const NO_MORE_FILES = 18;
57
3958/// The media is write protected.
4059pub const WRITE_PROTECT = 19;
60
4161/// The system cannot find the device specified.
4262pub const BAD_UNIT = 20;
63
4364/// The device is not ready.
4465pub const NOT_READY = 21;
66
4567/// The device does not recognize the command.
4668pub const BAD_COMMAND = 22;
69
4770/// Data error (cyclic redundancy check).
4871pub const CRC = 23;
72
4973/// The program issued a command but the command length is incorrect.
5074pub const BAD_LENGTH = 24;
75
5176/// The drive cannot locate a specific area or track on the disk.
5277pub const SEEK = 25;
78
5379/// The specified disk or diskette cannot be accessed.
5480pub const NOT_DOS_DISK = 26;
81
5582/// The drive cannot find the sector requested.
5683pub const SECTOR_NOT_FOUND = 27;
84
5785/// The printer is out of paper.
5886pub const OUT_OF_PAPER = 28;
87
5988/// The system cannot write to the specified device.
6089pub const WRITE_FAULT = 29;
90
6191/// The system cannot read from the specified device.
6292pub const READ_FAULT = 30;
93
6394/// A device attached to the system is not functioning.
6495pub const GEN_FAILURE = 31;
96
6597/// The process cannot access the file because it is being used by another process.
6698pub const SHARING_VIOLATION = 32;
99
67100/// The process cannot access the file because another process has locked a portion of the file.
68101pub const LOCK_VIOLATION = 33;
102
69103/// The wrong diskette is in the drive. Insert %2 (Volume Serial Number: %3) into drive %1.
70104pub const WRONG_DISK = 34;
105
71106/// Too many files opened for sharing.
72107pub const SHARING_BUFFER_EXCEEDED = 36;
108
73109/// Reached the end of the file.
74110pub const HANDLE_EOF = 38;
111
75112/// The disk is full.
76113pub const HANDLE_DISK_FULL = 39;
114
77115/// The request is not supported.
78116pub const NOT_SUPPORTED = 50;
117
79118/// Windows cannot find the network path. Verify that the network path is correct and the destination computer is not busy or turned off. If Windows still cannot find the network path, contact your network administrator.
80119pub const REM_NOT_LIST = 51;
120
81121/// You were not connected because a duplicate name exists on the network. If joining a domain, go to System in Control Panel to change the computer name and try again. If joining a workgroup, choose another workgroup name.
82122pub const DUP_NAME = 52;
123
83124/// The network path was not found.
84125pub const BAD_NETPATH = 53;
126
85127/// The network is busy.
86128pub const NETWORK_BUSY = 54;
129
87130/// The specified network resource or device is no longer available.
88131pub const DEV_NOT_EXIST = 55;
132
89133/// The network BIOS command limit has been reached.
90134pub const TOO_MANY_CMDS = 56;
135
91136/// A network adapter hardware error occurred.
92137pub const ADAP_HDW_ERR = 57;
138
93139/// The specified server cannot perform the requested operation.
94140pub const BAD_NET_RESP = 58;
141
95142/// An unexpected network error occurred.
96143pub const UNEXP_NET_ERR = 59;
144
97145/// The remote adapter is not compatible.
98146pub const BAD_REM_ADAP = 60;
147
99148/// The printer queue is full.
100149pub const PRINTQ_FULL = 61;
150
101151/// Space to store the file waiting to be printed is not available on the server.
102152pub const NO_SPOOL_SPACE = 62;
153
103154/// Your file waiting to be printed was deleted.
104155pub const PRINT_CANCELLED = 63;
156
105157/// The specified network name is no longer available.
106158pub const NETNAME_DELETED = 64;
159
107160/// Network access is denied.
108161pub const NETWORK_ACCESS_DENIED = 65;
162
109163/// The network resource type is not correct.
110164pub const BAD_DEV_TYPE = 66;
165
111166/// The network name cannot be found.
112167pub const BAD_NET_NAME = 67;
168
113169/// The name limit for the local computer network adapter card was exceeded.
114170pub const TOO_MANY_NAMES = 68;
171
115172/// The network BIOS session limit was exceeded.
116173pub const TOO_MANY_SESS = 69;
174
117175/// The remote server has been paused or is in the process of being started.
118176pub const SHARING_PAUSED = 70;
177
119178/// No more connections can be made to this remote computer at this time because there are already as many connections as the computer can accept.
120179pub const REQ_NOT_ACCEP = 71;
180
121181/// The specified printer or disk device has been paused.
122182pub const REDIR_PAUSED = 72;
183
123184/// The file exists.
124185pub const FILE_EXISTS = 80;
186
125187/// The directory or file cannot be created.
126188pub const CANNOT_MAKE = 82;
189
127190/// Fail on INT 24.
128191pub const FAIL_I24 = 83;
192
129193/// Storage to process this request is not available.
130194pub const OUT_OF_STRUCTURES = 84;
195
131196/// The local device name is already in use.
132197pub const ALREADY_ASSIGNED = 85;
198
133199/// The specified network password is not correct.
134200pub const INVALID_PASSWORD = 86;
201
135202/// The parameter is incorrect.
136203pub const INVALID_PARAMETER = 87;
204
137205/// A write fault occurred on the network.
138206pub const NET_WRITE_FAULT = 88;
207
139208/// The system cannot start another process at this time.
140209pub const NO_PROC_SLOTS = 89;
210
141211/// Cannot create another system semaphore.
142212pub const TOO_MANY_SEMAPHORES = 100;
213
143214/// The exclusive semaphore is owned by another process.
144215pub const EXCL_SEM_ALREADY_OWNED = 101;
216
145217/// The semaphore is set and cannot be closed.
146218pub const SEM_IS_SET = 102;
219
147220/// The semaphore cannot be set again.
148221pub const TOO_MANY_SEM_REQUESTS = 103;
222
149223/// Cannot request exclusive semaphores at interrupt time.
150224pub const INVALID_AT_INTERRUPT_TIME = 104;
225
151226/// The previous ownership of this semaphore has ended.
152227pub const SEM_OWNER_DIED = 105;
228
153229/// Insert the diskette for drive %1.
154230pub const SEM_USER_LIMIT = 106;
231
155232/// The program stopped because an alternate diskette was not inserted.
156233pub const DISK_CHANGE = 107;
234
157235/// The disk is in use or locked by another process.
158236pub const DRIVE_LOCKED = 108;
237
159238/// The pipe has been ended.
160239pub const BROKEN_PIPE = 109;
240
161241/// The system cannot open the device or file specified.
162242pub const OPEN_FAILED = 110;
243
163244/// The file name is too long.
164245pub const BUFFER_OVERFLOW = 111;
246
165247/// There is not enough space on the disk.
166248pub const DISK_FULL = 112;
249
167250/// No more internal file identifiers available.
168251pub const NO_MORE_SEARCH_HANDLES = 113;
252
169253/// The target internal file identifier is incorrect.
170254pub const INVALID_TARGET_HANDLE = 114;
255
171256/// The IOCTL call made by the application program is not correct.
172257pub const INVALID_CATEGORY = 117;
258
173259/// The verify-on-write switch parameter value is not correct.
174260pub const INVALID_VERIFY_SWITCH = 118;
261
175262/// The system does not support the command requested.
176263pub const BAD_DRIVER_LEVEL = 119;
264
177265/// This function is not supported on this system.
178266pub const CALL_NOT_IMPLEMENTED = 120;
267
179268/// The semaphore timeout period has expired.
180269pub const SEM_TIMEOUT = 121;
270
181271/// The data area passed to a system call is too small.
182272pub const INSUFFICIENT_BUFFER = 122;
273
183274/// The filename, directory name, or volume label syntax is incorrect.
184275pub const INVALID_NAME = 123;
276
185277/// The system call level is not correct.
186278pub const INVALID_LEVEL = 124;
279
187280/// The disk has no volume label.
188281pub const NO_VOLUME_LABEL = 125;
282
189283/// The specified module could not be found.
190284pub const MOD_NOT_FOUND = 126;
285
191286/// The specified procedure could not be found.
192287pub const PROC_NOT_FOUND = 127;
288
193289/// There are no child processes to wait for.
194290pub const WAIT_NO_CHILDREN = 128;
291
195292/// The %1 application cannot be run in Win32 mode.
196293pub const CHILD_NOT_COMPLETE = 129;
294
197295/// Attempt to use a file handle to an open disk partition for an operation other than raw disk I/O.
198296pub const DIRECT_ACCESS_HANDLE = 130;
297
199298/// An attempt was made to move the file pointer before the beginning of the file.
200299pub const NEGATIVE_SEEK = 131;
300
201301/// The file pointer cannot be set on the specified device or file.
202302pub const SEEK_ON_DEVICE = 132;
303
203304/// A JOIN or SUBST command cannot be used for a drive that contains previously joined drives.
204305pub const IS_JOIN_TARGET = 133;
306
205307/// An attempt was made to use a JOIN or SUBST command on a drive that has already been joined.
206308pub const IS_JOINED = 134;
309
207310/// An attempt was made to use a JOIN or SUBST command on a drive that has already been substituted.
208311pub const IS_SUBSTED = 135;
312
209313/// The system tried to delete the JOIN of a drive that is not joined.
210314pub const NOT_JOINED = 136;
315
211316/// The system tried to delete the substitution of a drive that is not substituted.
212317pub const NOT_SUBSTED = 137;
318
213319/// The system tried to join a drive to a directory on a joined drive.
214320pub const JOIN_TO_JOIN = 138;
321
215322/// The system tried to substitute a drive to a directory on a substituted drive.
216323pub const SUBST_TO_SUBST = 139;
324
217325/// The system tried to join a drive to a directory on a substituted drive.
218326pub const JOIN_TO_SUBST = 140;
327
219328/// The system tried to SUBST a drive to a directory on a joined drive.
220329pub const SUBST_TO_JOIN = 141;
330
221331/// The system cannot perform a JOIN or SUBST at this time.
222332pub const BUSY_DRIVE = 142;
333
223334/// The system cannot join or substitute a drive to or for a directory on the same drive.
224335pub const SAME_DRIVE = 143;
336
225337/// The directory is not a subdirectory of the root directory.
226338pub const DIR_NOT_ROOT = 144;
339
227340/// The directory is not empty.
228341pub const DIR_NOT_EMPTY = 145;
342
229343/// The path specified is being used in a substitute.
230344pub const IS_SUBST_PATH = 146;
345
231346/// Not enough resources are available to process this command.
232347pub const IS_JOIN_PATH = 147;
348
233349/// The path specified cannot be used at this time.
234350pub const PATH_BUSY = 148;
351
235352/// An attempt was made to join or substitute a drive for which a directory on the drive is the target of a previous substitute.
236353pub const IS_SUBST_TARGET = 149;
354
237355/// System trace information was not specified in your CONFIG.SYS file, or tracing is disallowed.
238356pub const SYSTEM_TRACE = 150;
357
239358/// The number of specified semaphore events for DosMuxSemWait is not correct.
240359pub const INVALID_EVENT_COUNT = 151;
360
241361/// DosMuxSemWait did not execute; too many semaphores are already set.
242362pub const TOO_MANY_MUXWAITERS = 152;
363
243364/// The DosMuxSemWait list is not correct.
244365pub const INVALID_LIST_FORMAT = 153;
366
245367/// The volume label you entered exceeds the label character limit of the target file system.
246368pub const LABEL_TOO_LONG = 154;
369
247370/// Cannot create another thread.
248371pub const TOO_MANY_TCBS = 155;
372
249373/// The recipient process has refused the signal.
250374pub const SIGNAL_REFUSED = 156;
375
251376/// The segment is already discarded and cannot be locked.
252377pub const DISCARDED = 157;
378
253379/// The segment is already unlocked.
254380pub const NOT_LOCKED = 158;
381
255382/// The address for the thread ID is not correct.
256383pub const BAD_THREADID_ADDR = 159;
384
257385/// One or more arguments are not correct.
258386pub const BAD_ARGUMENTS = 160;
387
259388/// The specified path is invalid.
260389pub const BAD_PATHNAME = 161;
390
261391/// A signal is already pending.
262392pub const SIGNAL_PENDING = 162;
393
263394/// No more threads can be created in the system.
264395pub const MAX_THRDS_REACHED = 164;
396
265397/// Unable to lock a region of a file.
266398pub const LOCK_FAILED = 167;
399
267400/// The requested resource is in use.
268401pub const BUSY = 170;
402
269403/// Device's command support detection is in progress.
270404pub const DEVICE_SUPPORT_IN_PROGRESS = 171;
405
271406/// A lock request was not outstanding for the supplied cancel region.
272407pub const CANCEL_VIOLATION = 173;
408
273409/// The file system does not support atomic changes to the lock type.
274410pub const ATOMIC_LOCKS_NOT_SUPPORTED = 174;
411
275412/// The system detected a segment number that was not correct.
276413pub const INVALID_SEGMENT_NUMBER = 180;
414
277415/// The operating system cannot run %1.
278416pub const INVALID_ORDINAL = 182;
417
279418/// Cannot create a file when that file already exists.
280419pub const ALREADY_EXISTS = 183;
420
281421/// The flag passed is not correct.
282422pub const INVALID_FLAG_NUMBER = 186;
423
283424/// The specified system semaphore name was not found.
284425pub const SEM_NOT_FOUND = 187;
426
285427/// The operating system cannot run %1.
286428pub const INVALID_STARTING_CODESEG = 188;
429
287430/// The operating system cannot run %1.
288431pub const INVALID_STACKSEG = 189;
432
289433/// The operating system cannot run %1.
290434pub const INVALID_MODULETYPE = 190;
435
291436/// Cannot run %1 in Win32 mode.
292437pub const INVALID_EXE_SIGNATURE = 191;
438
293439/// The operating system cannot run %1.
294440pub const EXE_MARKED_INVALID = 192;
441
295442/// %1 is not a valid Win32 application.
296443pub const BAD_EXE_FORMAT = 193;
444
297445/// The operating system cannot run %1.
298446pub const ITERATED_DATA_EXCEEDS_64k = 194;
447
299448/// The operating system cannot run %1.
300449pub const INVALID_MINALLOCSIZE = 195;
450
301451/// The operating system cannot run this application program.
302452pub const DYNLINK_FROM_INVALID_RING = 196;
453
303454/// The operating system is not presently configured to run this application.
304455pub const IOPL_NOT_ENABLED = 197;
456
305457/// The operating system cannot run %1.
306458pub const INVALID_SEGDPL = 198;
459
307460/// The operating system cannot run this application program.
308461pub const AUTODATASEG_EXCEEDS_64k = 199;
462
309463/// The code segment cannot be greater than or equal to 64K.
310464pub const RING2SEG_MUST_BE_MOVABLE = 200;
465
311466/// The operating system cannot run %1.
312467pub const RELOC_CHAIN_XEEDS_SEGLIM = 201;
468
313469/// The operating system cannot run %1.
314470pub const INFLOOP_IN_RELOC_CHAIN = 202;
471
315472/// The system could not find the environment option that was entered.
316473pub const ENVVAR_NOT_FOUND = 203;
474
317475/// No process in the command subtree has a signal handler.
318476pub const NO_SIGNAL_SENT = 205;
477
319478/// The filename or extension is too long.
320479pub const FILENAME_EXCED_RANGE = 206;
480
321481/// The ring 2 stack is in use.
322482pub const RING2_STACK_IN_USE = 207;
483
323484/// The global filename characters, * or ?, are entered incorrectly or too many global filename characters are specified.
324485pub const META_EXPANSION_TOO_LONG = 208;
486
325487/// The signal being posted is not correct.
326488pub const INVALID_SIGNAL_NUMBER = 209;
489
327490/// The signal handler cannot be set.
328491pub const THREAD_1_INACTIVE = 210;
492
329493/// The segment is locked and cannot be reallocated.
330494pub const LOCKED = 212;
495
331496/// Too many dynamic-link modules are attached to this program or dynamic-link module.
332497pub const TOO_MANY_MODULES = 214;
498
333499/// Cannot nest calls to LoadModule.
334500pub const NESTING_NOT_ALLOWED = 215;
501
335502/// This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher.
336503pub const EXE_MACHINE_TYPE_MISMATCH = 216;
504
337505/// The image file %1 is signed, unable to modify.
338506pub const EXE_CANNOT_MODIFY_SIGNED_BINARY = 217;
507
339508/// The image file %1 is strong signed, unable to modify.
340509pub const EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY = 218;
510
341511/// This file is checked out or locked for editing by another user.
342512pub const FILE_CHECKED_OUT = 220;
513
343514/// The file must be checked out before saving changes.
344515pub const CHECKOUT_REQUIRED = 221;
516
345517/// The file type being saved or retrieved has been blocked.
346518pub const BAD_FILE_TYPE = 222;
519
347520/// The file size exceeds the limit allowed and cannot be saved.
348521pub const FILE_TOO_LARGE = 223;
522
349523/// Access Denied. Before opening files in this location, you must first add the web site to your trusted sites list, browse to the web site, and select the option to login automatically.
350524pub const FORMS_AUTH_REQUIRED = 224;
525
351526/// Operation did not complete successfully because the file contains a virus or potentially unwanted software.
352527pub const VIRUS_INFECTED = 225;
528
353529/// This file contains a virus or potentially unwanted software and cannot be opened. Due to the nature of this virus or potentially unwanted software, the file has been removed from this location.
354530pub const VIRUS_DELETED = 226;
531
355532/// The pipe is local.
356533pub const PIPE_LOCAL = 229;
534
357535/// The pipe state is invalid.
358536pub const BAD_PIPE = 230;
537
359538/// All pipe instances are busy.
360539pub const PIPE_BUSY = 231;
540
361541/// The pipe is being closed.
362542pub const NO_DATA = 232;
543
363544/// No process is on the other end of the pipe.
364545pub const PIPE_NOT_CONNECTED = 233;
546
365547/// More data is available.
366548pub const MORE_DATA = 234;
549
367550/// The session was canceled.
368551pub const VC_DISCONNECTED = 240;
552
369553/// The specified extended attribute name was invalid.
370554pub const INVALID_EA_NAME = 254;
555
371556/// The extended attributes are inconsistent.
372557pub const EA_LIST_INCONSISTENT = 255;
558
373559/// The wait operation timed out.
374560pub const IMEOUT = 258;
561
375562/// No more data is available.
376563pub const NO_MORE_ITEMS = 259;
564
377565/// The copy functions cannot be used.
378566pub const CANNOT_COPY = 266;
567
379568/// The directory name is invalid.
380569pub const DIRECTORY = 267;
570
381571/// The extended attributes did not fit in the buffer.
382572pub const EAS_DIDNT_FIT = 275;
573
383574/// The extended attribute file on the mounted file system is corrupt.
384575pub const EA_FILE_CORRUPT = 276;
576
385577/// The extended attribute table file is full.
386578pub const EA_TABLE_FULL = 277;
579
387580/// The specified extended attribute handle is invalid.
388581pub const INVALID_EA_HANDLE = 278;
582
389583/// The mounted file system does not support extended attributes.
390584pub const EAS_NOT_SUPPORTED = 282;
585
391586/// Attempt to release mutex not owned by caller.
392587pub const NOT_OWNER = 288;
588
393589/// Too many posts were made to a semaphore.
394590pub const TOO_MANY_POSTS = 298;
591
395592/// Only part of a ReadProcessMemory or WriteProcessMemory request was completed.
396593pub const PARTIAL_COPY = 299;
594
397595/// The oplock request is denied.
398596pub const OPLOCK_NOT_GRANTED = 300;
597
399598/// An invalid oplock acknowledgment was received by the system.
400599pub const INVALID_OPLOCK_PROTOCOL = 301;
600
401601/// The volume is too fragmented to complete this operation.
402602pub const DISK_TOO_FRAGMENTED = 302;
603
403604/// The file cannot be opened because it is in the process of being deleted.
404605pub const DELETE_PENDING = 303;
606
405607/// Short name settings may not be changed on this volume due to the global registry setting.
406608pub const INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING = 304;
609
407610/// Short names are not enabled on this volume.
408611pub const SHORT_NAMES_NOT_ENABLED_ON_VOLUME = 305;
612
409613/// The security stream for the given volume is in an inconsistent state. Please run CHKDSK on the volume.
410614pub const SECURITY_STREAM_IS_INCONSISTENT = 306;
615
411616/// A requested file lock operation cannot be processed due to an invalid byte range.
412617pub const INVALID_LOCK_RANGE = 307;
618
413619/// The subsystem needed to support the image type is not present.
414620pub const IMAGE_SUBSYSTEM_NOT_PRESENT = 308;
621
415622/// The specified file already has a notification GUID associated with it.
416623pub const NOTIFICATION_GUID_ALREADY_DEFINED = 309;
624
417625/// An invalid exception handler routine has been detected.
418626pub const INVALID_EXCEPTION_HANDLER = 310;
627
419628/// Duplicate privileges were specified for the token.
420629pub const DUPLICATE_PRIVILEGES = 311;
630
421631/// No ranges for the specified operation were able to be processed.
422632pub const NO_RANGES_PROCESSED = 312;
633
423634/// Operation is not allowed on a file system internal file.
424635pub const NOT_ALLOWED_ON_SYSTEM_FILE = 313;
636
425637/// The physical resources of this disk have been exhausted.
426638pub const DISK_RESOURCES_EXHAUSTED = 314;
639
427640/// The token representing the data is invalid.
428641pub const INVALID_TOKEN = 315;
642
429643/// The device does not support the command feature.
430644pub const DEVICE_FEATURE_NOT_SUPPORTED = 316;
645
431646/// The system cannot find message text for message number 0x%1 in the message file for %2.
432647pub const MR_MID_NOT_FOUND = 317;
648
433649/// The scope specified was not found.
434650pub const SCOPE_NOT_FOUND = 318;
651
435652/// The Central Access Policy specified is not defined on the target machine.
436653pub const UNDEFINED_SCOPE = 319;
654
437655/// The Central Access Policy obtained from Active Directory is invalid.
438656pub const INVALID_CAP = 320;
657
439658/// The device is unreachable.
440659pub const DEVICE_UNREACHABLE = 321;
660
441661/// The target device has insufficient resources to complete the operation.
442662pub const DEVICE_NO_RESOURCES = 322;
663
443664/// A data integrity checksum error occurred. Data in the file stream is corrupt.
444665pub const DATA_CHECKSUM_ERROR = 323;
666
445667/// An attempt was made to modify both a KERNEL and normal Extended Attribute (EA) in the same operation.
446668pub const INTERMIXED_KERNEL_EA_OPERATION = 324;
669
447670/// Device does not support file-level TRIM.
448671pub const FILE_LEVEL_TRIM_NOT_SUPPORTED = 326;
672
449673/// The command specified a data offset that does not align to the device's granularity/alignment.
450674pub const OFFSET_ALIGNMENT_VIOLATION = 327;
675
451676/// The command specified an invalid field in its parameter list.
452677pub const INVALID_FIELD_IN_PARAMETER_LIST = 328;
678
453679/// An operation is currently in progress with the device.
454680pub const OPERATION_IN_PROGRESS = 329;
681
455682/// An attempt was made to send down the command via an invalid path to the target device.
456683pub const BAD_DEVICE_PATH = 330;
684
457685/// The command specified a number of descriptors that exceeded the maximum supported by the device.
458686pub const TOO_MANY_DESCRIPTORS = 331;
687
459688/// Scrub is disabled on the specified file.
460689pub const SCRUB_DATA_DISABLED = 332;
690
461691/// The storage device does not provide redundancy.
462692pub const NOT_REDUNDANT_STORAGE = 333;
693
463694/// An operation is not supported on a resident file.
464695pub const RESIDENT_FILE_NOT_SUPPORTED = 334;
696
465697/// An operation is not supported on a compressed file.
466698pub const COMPRESSED_FILE_NOT_SUPPORTED = 335;
699
467700/// An operation is not supported on a directory.
468701pub const DIRECTORY_NOT_SUPPORTED = 336;
702
469703/// The specified copy of the requested data could not be read.
470704pub const NOT_READ_FROM_COPY = 337;
705
471706/// No action was taken as a system reboot is required.
472707pub const FAIL_NOACTION_REBOOT = 350;
708
473709/// The shutdown operation failed.
474710pub const FAIL_SHUTDOWN = 351;
711
475712/// The restart operation failed.
476713pub const FAIL_RESTART = 352;
714
477715/// The maximum number of sessions has been reached.
478716pub const MAX_SESSIONS_REACHED = 353;
717
479718/// The thread is already in background processing mode.
480719pub const THREAD_MODE_ALREADY_BACKGROUND = 400;
720
481721/// The thread is not in background processing mode.
482722pub const THREAD_MODE_NOT_BACKGROUND = 401;
723
483724/// The process is already in background processing mode.
484725pub const PROCESS_MODE_ALREADY_BACKGROUND = 402;
726
485727/// The process is not in background processing mode.
486728pub const PROCESS_MODE_NOT_BACKGROUND = 403;
729
487730/// Attempt to access invalid address.
488731pub const INVALID_ADDRESS = 487;
732
489733/// User profile cannot be loaded.
490734pub const USER_PROFILE_LOAD = 500;
735
491736/// Arithmetic result exceeded 32 bits.
492737pub const ARITHMETIC_OVERFLOW = 534;
738
493739/// There is a process on other end of the pipe.
494740pub const PIPE_CONNECTED = 535;
741
495742/// Waiting for a process to open the other end of the pipe.
496743pub const PIPE_LISTENING = 536;
744
497745/// Application verifier has found an error in the current process.
498746pub const VERIFIER_STOP = 537;
747
499748/// An error occurred in the ABIOS subsystem.
500749pub const ABIOS_ERROR = 538;
750
501751/// A warning occurred in the WX86 subsystem.
502752pub const WX86_WARNING = 539;
753
503754/// An error occurred in the WX86 subsystem.
504755pub const WX86_ERROR = 540;
756
505757/// An attempt was made to cancel or set a timer that has an associated APC and the subject thread is not the thread that originally set the timer with an associated APC routine.
506758pub const TIMER_NOT_CANCELED = 541;
759
507760/// Unwind exception code.
508761pub const UNWIND = 542;
762
509763/// An invalid or unaligned stack was encountered during an unwind operation.
510764pub const BAD_STACK = 543;
765
511766/// An invalid unwind target was encountered during an unwind operation.
512767pub const INVALID_UNWIND_TARGET = 544;
768
513769/// Invalid Object Attributes specified to NtCreatePort or invalid Port Attributes specified to NtConnectPort
514770pub const INVALID_PORT_ATTRIBUTES = 545;
771
515772/// Length of message passed to NtRequestPort or NtRequestWaitReplyPort was longer than the maximum message allowed by the port.
516773pub const PORT_MESSAGE_TOO_LONG = 546;
774
517775/// An attempt was made to lower a quota limit below the current usage.
518776pub const INVALID_QUOTA_LOWER = 547;
777
519778/// An attempt was made to attach to a device that was already attached to another device.
520779pub const DEVICE_ALREADY_ATTACHED = 548;
780
521781/// An attempt was made to execute an instruction at an unaligned address and the host system does not support unaligned instruction references.
522782pub const INSTRUCTION_MISALIGNMENT = 549;
783
523784/// Profiling not started.
524785pub const PROFILING_NOT_STARTED = 550;
786
525787/// Profiling not stopped.
526788pub const PROFILING_NOT_STOPPED = 551;
789
527790/// The passed ACL did not contain the minimum required information.
528791pub const COULD_NOT_INTERPRET = 552;
792
529793/// The number of active profiling objects is at the maximum and no more may be started.
530794pub const PROFILING_AT_LIMIT = 553;
795
531796/// Used to indicate that an operation cannot continue without blocking for I/O.
532797pub const CANT_WAIT = 554;
798
533799/// Indicates that a thread attempted to terminate itself by default (called NtTerminateThread with NULL) and it was the last thread in the current process.
534800pub const CANT_TERMINATE_SELF = 555;
801
535802/// If an MM error is returned which is not defined in the standard FsRtl filter, it is converted to one of the following errors which is guaranteed to be in the filter. In this case information is lost, however, the filter correctly handles the exception.
536803pub const UNEXPECTED_MM_CREATE_ERR = 556;
804
537805/// If an MM error is returned which is not defined in the standard FsRtl filter, it is converted to one of the following errors which is guaranteed to be in the filter. In this case information is lost, however, the filter correctly handles the exception.
538806pub const UNEXPECTED_MM_MAP_ERROR = 557;
807
539808/// If an MM error is returned which is not defined in the standard FsRtl filter, it is converted to one of the following errors which is guaranteed to be in the filter. In this case information is lost, however, the filter correctly handles the exception.
540809pub const UNEXPECTED_MM_EXTEND_ERR = 558;
810
541811/// A malformed function table was encountered during an unwind operation.
542812pub const BAD_FUNCTION_TABLE = 559;
813
543814/// Indicates that an attempt was made to assign protection to a file system file or directory and one of the SIDs in the security descriptor could not be translated into a GUID that could be stored by the file system. This causes the protection attempt to fail, which may cause a file creation attempt to fail.
544815pub const NO_GUID_TRANSLATION = 560;
816
545817/// Indicates that an attempt was made to grow an LDT by setting its size, or that the size was not an even number of selectors.
546818pub const INVALID_LDT_SIZE = 561;
819
547820/// Indicates that the starting value for the LDT information was not an integral multiple of the selector size.
548821pub const INVALID_LDT_OFFSET = 563;
822
549823/// Indicates that the user supplied an invalid descriptor when trying to set up Ldt descriptors.
550824pub const INVALID_LDT_DESCRIPTOR = 564;
825
551826/// Indicates a process has too many threads to perform the requested action. For example, assignment of a primary token may only be performed when a process has zero or one threads.
552827pub const TOO_MANY_THREADS = 565;
828
553829/// An attempt was made to operate on a thread within a specific process, but the thread specified is not in the process specified.
554830pub const THREAD_NOT_IN_PROCESS = 566;
831
555832/// Page file quota was exceeded.
556833pub const PAGEFILE_QUOTA_EXCEEDED = 567;
834
557835/// The Netlogon service cannot start because another Netlogon service running in the domain conflicts with the specified role.
558836pub const LOGON_SERVER_CONFLICT = 568;
837
559838/// The SAM database on a Windows Server is significantly out of synchronization with the copy on the Domain Controller. A complete synchronization is required.
560839pub const SYNCHRONIZATION_REQUIRED = 569;
840
561841/// The NtCreateFile API failed. This error should never be returned to an application, it is a place holder for the Windows Lan Manager Redirector to use in its internal error mapping routines.
562842pub const NET_OPEN_FAILED = 570;
843
563844/// {Privilege Failed} The I/O permissions for the process could not be changed.
564845pub const IO_PRIVILEGE_FAILED = 571;
846
565847/// {Application Exit by CTRL+C} The application terminated as a result of a CTRL+C.
566848pub const CONTROL_C_EXIT = 572;
849
567850/// {Missing System File} The required system file %hs is bad or missing.
568851pub const MISSING_SYSTEMFILE = 573;
852
569853/// {Application Error} The exception %s (0x%08lx) occurred in the application at location 0x%08lx.
570854pub const UNHANDLED_EXCEPTION = 574;
855
571856/// {Application Error} The application was unable to start correctly (0x%lx). Click OK to close the application.
572857pub const APP_INIT_FAILURE = 575;
858
573859/// {Unable to Create Paging File} The creation of the paging file %hs failed (%lx). The requested size was %ld.
574860pub const PAGEFILE_CREATE_FAILED = 576;
861
575862/// Windows cannot verify the digital signature for this file. A recent hardware or software change might have installed a file that is signed incorrectly or damaged, or that might be malicious software from an unknown source.
576863pub const INVALID_IMAGE_HASH = 577;
864
577865/// {No Paging File Specified} No paging file was specified in the system configuration.
578866pub const NO_PAGEFILE = 578;
867
579868/// {EXCEPTION} A real-mode application issued a floating-point instruction and floating-point hardware is not present.
580869pub const ILLEGAL_FLOAT_CONTEXT = 579;
870
581871/// An event pair synchronization operation was performed using the thread specific client/server event pair object, but no event pair object was associated with the thread.
582872pub const NO_EVENT_PAIR = 580;
873
583874/// A Windows Server has an incorrect configuration.
584875pub const DOMAIN_CTRLR_CONFIG_ERROR = 581;
876
585877/// An illegal character was encountered. For a multi-byte character set this includes a lead byte without a succeeding trail byte. For the Unicode character set this includes the characters 0xFFFF and 0xFFFE.
586878pub const ILLEGAL_CHARACTER = 582;
879
587880/// The Unicode character is not defined in the Unicode character set installed on the system.
588881pub const UNDEFINED_CHARACTER = 583;
882
589883/// The paging file cannot be created on a floppy diskette.
590884pub const FLOPPY_VOLUME = 584;
885
591886/// The system BIOS failed to connect a system interrupt to the device or bus for which the device is connected.
592887pub const BIOS_FAILED_TO_CONNECT_INTERRUPT = 585;
888
593889/// This operation is only allowed for the Primary Domain Controller of the domain.
594890pub const BACKUP_CONTROLLER = 586;
891
595892/// An attempt was made to acquire a mutant such that its maximum count would have been exceeded.
596893pub const MUTANT_LIMIT_EXCEEDED = 587;
894
597895/// A volume has been accessed for which a file system driver is required that has not yet been loaded.
598896pub const FS_DRIVER_REQUIRED = 588;
897
599898/// {Registry File Failure} The registry cannot load the hive (file): %hs or its log or alternate. It is corrupt, absent, or not writable.
600899pub const CANNOT_LOAD_REGISTRY_FILE = 589;
900
601901/// {Unexpected Failure in DebugActiveProcess} An unexpected failure occurred while processing a DebugActiveProcess API request. You may choose OK to terminate the process, or Cancel to ignore the error.
602902pub const DEBUG_ATTACH_FAILED = 590;
903
603904/// {Fatal System Error} The %hs system process terminated unexpectedly with a status of 0x%08x (0x%08x 0x%08x). The system has been shut down.
604905pub const SYSTEM_PROCESS_TERMINATED = 591;
906
605907/// {Data Not Accepted} The TDI client could not handle the data received during an indication.
606908pub const DATA_NOT_ACCEPTED = 592;
909
607910/// NTVDM encountered a hard error.
608911pub const VDM_HARD_ERROR = 593;
912
609913/// {Cancel Timeout} The driver %hs failed to complete a cancelled I/O request in the allotted time.
610914pub const DRIVER_CANCEL_TIMEOUT = 594;
915
611916/// {Reply Message Mismatch} An attempt was made to reply to an LPC message, but the thread specified by the client ID in the message was not waiting on that message.
612917pub const REPLY_MESSAGE_MISMATCH = 595;
918
613919/// {Delayed Write Failed} Windows was unable to save all the data for the file %hs. The data has been lost. This error may be caused by a failure of your computer hardware or network connection. Please try to save this file elsewhere.
614920pub const LOST_WRITEBEHIND_DATA = 596;
921
615922/// The parameter(s) passed to the server in the client/server shared memory window were invalid. Too much data may have been put in the shared memory window.
616923pub const CLIENT_SERVER_PARAMETERS_INVALID = 597;
924
617925/// The stream is not a tiny stream.
618926pub const NOT_TINY_STREAM = 598;
927
619928/// The request must be handled by the stack overflow code.
620929pub const STACK_OVERFLOW_READ = 599;
930
621931/// Internal OFS status codes indicating how an allocation operation is handled. Either it is retried after the containing onode is moved or the extent stream is converted to a large stream.
622932pub const CONVERT_TO_LARGE = 600;
933
623934/// The attempt to find the object found an object matching by ID on the volume but it is out of the scope of the handle used for the operation.
624935pub const FOUND_OUT_OF_SCOPE = 601;
936
625937/// The bucket array must be grown. Retry transaction after doing so.
626938pub const ALLOCATE_BUCKET = 602;
939
627940/// The user/kernel marshalling buffer has overflowed.
628941pub const MARSHALL_OVERFLOW = 603;
942
629943/// The supplied variant structure contains invalid data.
630944pub const INVALID_VARIANT = 604;
945
631946/// The specified buffer contains ill-formed data.
632947pub const BAD_COMPRESSION_BUFFER = 605;
948
633949/// {Audit Failed} An attempt to generate a security audit failed.
634950pub const AUDIT_FAILED = 606;
951
635952/// The timer resolution was not previously set by the current process.
636953pub const TIMER_RESOLUTION_NOT_SET = 607;
954
637955/// There is insufficient account information to log you on.
638956pub const INSUFFICIENT_LOGON_INFO = 608;
957
639958/// {Invalid DLL Entrypoint} The dynamic link library %hs is not written correctly. The stack pointer has been left in an inconsistent state. The entrypoint should be declared as WINAPI or STDCALL. Select YES to fail the DLL load. Select NO to continue execution. Selecting NO may cause the application to operate incorrectly.
640959pub const BAD_DLL_ENTRYPOINT = 609;
960
641961/// {Invalid Service Callback Entrypoint} The %hs service is not written correctly. The stack pointer has been left in an inconsistent state. The callback entrypoint should be declared as WINAPI or STDCALL. Selecting OK will cause the service to continue operation. However, the service process may operate incorrectly.
642962pub const BAD_SERVICE_ENTRYPOINT = 610;
963
643964/// There is an IP address conflict with another system on the network.
644965pub const IP_ADDRESS_CONFLICT1 = 611;
966
645967/// There is an IP address conflict with another system on the network.
646968pub const IP_ADDRESS_CONFLICT2 = 612;
969
647970/// {Low On Registry Space} The system has reached the maximum size allowed for the system part of the registry. Additional storage requests will be ignored.
648971pub const REGISTRY_QUOTA_LIMIT = 613;
972
649973/// A callback return system service cannot be executed when no callback is active.
650974pub const NO_CALLBACK_ACTIVE = 614;
975
651976/// The password provided is too short to meet the policy of your user account. Please choose a longer password.
652977pub const PWD_TOO_SHORT = 615;
978
653979/// The policy of your user account does not allow you to change passwords too frequently. This is done to prevent users from changing back to a familiar, but potentially discovered, password. If you feel your password has been compromised then please contact your administrator immediately to have a new one assigned.
654980pub const PWD_TOO_RECENT = 616;
981
655982/// You have attempted to change your password to one that you have used in the past. The policy of your user account does not allow this. Please select a password that you have not previously used.
656983pub const PWD_HISTORY_CONFLICT = 617;
984
657985/// The specified compression format is unsupported.
658986pub const UNSUPPORTED_COMPRESSION = 618;
987
659988/// The specified hardware profile configuration is invalid.
660989pub const INVALID_HW_PROFILE = 619;
990
661991/// The specified Plug and Play registry device path is invalid.
662992pub const INVALID_PLUGPLAY_DEVICE_PATH = 620;
993
663994/// The specified quota list is internally inconsistent with its descriptor.
664995pub const QUOTA_LIST_INCONSISTENT = 621;
996
665997/// {Windows Evaluation Notification} The evaluation period for this installation of Windows has expired. This system will shutdown in 1 hour. To restore access to this installation of Windows, please upgrade this installation using a licensed distribution of this product.
666998pub const EVALUATION_EXPIRATION = 622;
999
6671000/// {Illegal System DLL Relocation} The system DLL %hs was relocated in memory. The application will not run properly. The relocation occurred because the DLL %hs occupied an address range reserved for Windows system DLLs. The vendor supplying the DLL should be contacted for a new DLL.
6681001pub const ILLEGAL_DLL_RELOCATION = 623;
1002
6691003/// {DLL Initialization Failed} The application failed to initialize because the window station is shutting down.
6701004pub const DLL_INIT_FAILED_LOGOFF = 624;
1005
6711006/// The validation process needs to continue on to the next step.
6721007pub const VALIDATE_CONTINUE = 625;
1008
6731009/// There are no more matches for the current index enumeration.
6741010pub const NO_MORE_MATCHES = 626;
1011
6751012/// The range could not be added to the range list because of a conflict.
6761013pub const RANGE_LIST_CONFLICT = 627;
1014
6771015/// The server process is running under a SID different than that required by client.
6781016pub const SERVER_SID_MISMATCH = 628;
1017
6791018/// A group marked use for deny only cannot be enabled.
6801019pub const CANT_ENABLE_DENY_ONLY = 629;
1020
6811021/// {EXCEPTION} Multiple floating point faults.
6821022pub const FLOAT_MULTIPLE_FAULTS = 630;
1023
6831024/// {EXCEPTION} Multiple floating point traps.
6841025pub const FLOAT_MULTIPLE_TRAPS = 631;
1026
6851027/// The requested interface is not supported.
6861028pub const NOINTERFACE = 632;
1029
6871030/// {System Standby Failed} The driver %hs does not support standby mode. Updating this driver may allow the system to go to standby mode.
6881031pub const DRIVER_FAILED_SLEEP = 633;
1032
6891033/// The system file %1 has become corrupt and has been replaced.
6901034pub const CORRUPT_SYSTEM_FILE = 634;
1035
6911036/// {Virtual Memory Minimum Too Low} Your system is low on virtual memory. Windows is increasing the size of your virtual memory paging file. During this process, memory requests for some applications may be denied. For more information, see Help.
6921037pub const COMMITMENT_MINIMUM = 635;
1038
6931039/// A device was removed so enumeration must be restarted.
6941040pub const PNP_RESTART_ENUMERATION = 636;
1041
6951042/// {Fatal System Error} The system image %s is not properly signed. The file has been replaced with the signed file. The system has been shut down.
6961043pub const SYSTEM_IMAGE_BAD_SIGNATURE = 637;
1044
6971045/// Device will not start without a reboot.
6981046pub const PNP_REBOOT_REQUIRED = 638;
1047
6991048/// There is not enough power to complete the requested operation.
7001049pub const INSUFFICIENT_POWER = 639;
1050
7011051/// ERROR_MULTIPLE_FAULT_VIOLATION
7021052pub const MULTIPLE_FAULT_VIOLATION = 640;
1053
7031054/// The system is in the process of shutting down.
7041055pub const SYSTEM_SHUTDOWN = 641;
1056
7051057/// An attempt to remove a processes DebugPort was made, but a port was not already associated with the process.
7061058pub const PORT_NOT_SET = 642;
1059
7071060/// This version of Windows is not compatible with the behavior version of directory forest, domain or domain controller.
7081061pub const DS_VERSION_CHECK_FAILURE = 643;
1062
7091063/// The specified range could not be found in the range list.
7101064pub const RANGE_NOT_FOUND = 644;
1065
7111066/// The driver was not loaded because the system is booting into safe mode.
7121067pub const NOT_SAFE_MODE_DRIVER = 646;
1068
7131069/// The driver was not loaded because it failed its initialization call.
7141070pub const FAILED_DRIVER_ENTRY = 647;
1071
7151072/// The "%hs" encountered an error while applying power or reading the device configuration. This may be caused by a failure of your hardware or by a poor connection.
7161073pub const DEVICE_ENUMERATION_ERROR = 648;
1074
7171075/// The create operation failed because the name contained at least one mount point which resolves to a volume to which the specified device object is not attached.
7181076pub const MOUNT_POINT_NOT_RESOLVED = 649;
1077
7191078/// The device object parameter is either not a valid device object or is not attached to the volume specified by the file name.
7201079pub const INVALID_DEVICE_OBJECT_PARAMETER = 650;
1080
7211081/// A Machine Check Error has occurred. Please check the system eventlog for additional information.
7221082pub const MCA_OCCURED = 651;
1083
7231084/// There was error [%2] processing the driver database.
7241085pub const DRIVER_DATABASE_ERROR = 652;
1086
7251087/// System hive size has exceeded its limit.
7261088pub const SYSTEM_HIVE_TOO_LARGE = 653;
1089
7271090/// The driver could not be loaded because a previous version of the driver is still in memory.
7281091pub const DRIVER_FAILED_PRIOR_UNLOAD = 654;
1092
7291093/// {Volume Shadow Copy Service} Please wait while the Volume Shadow Copy Service prepares volume %hs for hibernation.
7301094pub const VOLSNAP_PREPARE_HIBERNATE = 655;
1095
7311096/// The system has failed to hibernate (The error code is %hs). Hibernation will be disabled until the system is restarted.
7321097pub const HIBERNATION_FAILURE = 656;
1098
7331099/// The password provided is too long to meet the policy of your user account. Please choose a shorter password.
7341100pub const PWD_TOO_LONG = 657;
1101
7351102/// The requested operation could not be completed due to a file system limitation.
7361103pub const FILE_SYSTEM_LIMITATION = 665;
1104
7371105/// An assertion failure has occurred.
7381106pub const ASSERTION_FAILURE = 668;
1107
7391108/// An error occurred in the ACPI subsystem.
7401109pub const ACPI_ERROR = 669;
1110
7411111/// WOW Assertion Error.
7421112pub const WOW_ASSERTION = 670;
1113
7431114/// A device is missing in the system BIOS MPS table. This device will not be used. Please contact your system vendor for system BIOS update.
7441115pub const PNP_BAD_MPS_TABLE = 671;
1116
7451117/// A translator failed to translate resources.
7461118pub const PNP_TRANSLATION_FAILED = 672;
1119
7471120/// A IRQ translator failed to translate resources.
7481121pub const PNP_IRQ_TRANSLATION_FAILED = 673;
1122
7491123/// Driver %2 returned invalid ID for a child device (%3).
7501124pub const PNP_INVALID_ID = 674;
1125
7511126/// {Kernel Debugger Awakened} the system debugger was awakened by an interrupt.
7521127pub const WAKE_SYSTEM_DEBUGGER = 675;
1128
7531129/// {Handles Closed} Handles to objects have been automatically closed as a result of the requested operation.
7541130pub const HANDLES_CLOSED = 676;
1131
7551132/// {Too Much Information} The specified access control list (ACL) contained more information than was expected.
7561133pub const EXTRANEOUS_INFORMATION = 677;
1134
7571135/// This warning level status indicates that the transaction state already exists for the registry sub-tree, but that a transaction commit was previously aborted. The commit has NOT been completed, but has not been rolled back either (so it may still be committed if desired).
7581136pub const RXACT_COMMIT_NECESSARY = 678;
1137
7591138/// {Media Changed} The media may have changed.
7601139pub const MEDIA_CHECK = 679;
1140
7611141/// {GUID Substitution} During the translation of a global identifier (GUID) to a Windows security ID (SID), no administratively-defined GUID prefix was found. A substitute prefix was used, which will not compromise system security. However, this may provide a more restrictive access than intended.
7621142pub const GUID_SUBSTITUTION_MADE = 680;
1143
7631144/// The create operation stopped after reaching a symbolic link.
7641145pub const STOPPED_ON_SYMLINK = 681;
1146
7651147/// A long jump has been executed.
7661148pub const LONGJUMP = 682;
1149
7671150/// The Plug and Play query operation was not successful.
7681151pub const PLUGPLAY_QUERY_VETOED = 683;
1152
7691153/// A frame consolidation has been executed.
7701154pub const UNWIND_CONSOLIDATE = 684;
1155
7711156/// {Registry Hive Recovered} Registry hive (file): %hs was corrupted and it has been recovered. Some data might have been lost.
7721157pub const REGISTRY_HIVE_RECOVERED = 685;
1158
7731159/// The application is attempting to run executable code from the module %hs. This may be insecure. An alternative, %hs, is available. Should the application use the secure module %hs?
7741160pub const DLL_MIGHT_BE_INSECURE = 686;
1161
7751162/// The application is loading executable code from the module %hs. This is secure, but may be incompatible with previous releases of the operating system. An alternative, %hs, is available. Should the application use the secure module %hs?
7761163pub const DLL_MIGHT_BE_INCOMPATIBLE = 687;
1164
7771165/// Debugger did not handle the exception.
7781166pub const DBG_EXCEPTION_NOT_HANDLED = 688;
1167
7791168/// Debugger will reply later.
7801169pub const DBG_REPLY_LATER = 689;
1170
7811171/// Debugger cannot provide handle.
7821172pub const DBG_UNABLE_TO_PROVIDE_HANDLE = 690;
1173
7831174/// Debugger terminated thread.
7841175pub const DBG_TERMINATE_THREAD = 691;
1176
7851177/// Debugger terminated process.
7861178pub const DBG_TERMINATE_PROCESS = 692;
1179
7871180/// Debugger got control C.
7881181pub const DBG_CONTROL_C = 693;
1182
7891183/// Debugger printed exception on control C.
7901184pub const DBG_PRINTEXCEPTION_C = 694;
1185
7911186/// Debugger received RIP exception.
7921187pub const DBG_RIPEXCEPTION = 695;
1188
7931189/// Debugger received control break.
7941190pub const DBG_CONTROL_BREAK = 696;
1191
7951192/// Debugger command communication exception.
7961193pub const DBG_COMMAND_EXCEPTION = 697;
1194
7971195/// {Object Exists} An attempt was made to create an object and the object name already existed.
7981196pub const OBJECT_NAME_EXISTS = 698;
1197
7991198/// {Thread Suspended} A thread termination occurred while the thread was suspended. The thread was resumed, and termination proceeded.
8001199pub const THREAD_WAS_SUSPENDED = 699;
1200
8011201/// {Image Relocated} An image file could not be mapped at the address specified in the image file. Local fixups must be performed on this image.
8021202pub const IMAGE_NOT_AT_BASE = 700;
1203
8031204/// This informational level status indicates that a specified registry sub-tree transaction state did not yet exist and had to be created.
8041205pub const RXACT_STATE_CREATED = 701;
1206
8051207/// {Segment Load} A virtual DOS machine (VDM) is loading, unloading, or moving an MS-DOS or Win16 program segment image. An exception is raised so a debugger can load, unload or track symbols and breakpoints within these 16-bit segments.
8061208pub const SEGMENT_NOTIFICATION = 702;
1209
8071210/// {Invalid Current Directory} The process cannot switch to the startup current directory %hs. Select OK to set current directory to %hs, or select CANCEL to exit.
8081211pub const BAD_CURRENT_DIRECTORY = 703;
1212
8091213/// {Redundant Read} To satisfy a read request, the NT fault-tolerant file system successfully read the requested data from a redundant copy. This was done because the file system encountered a failure on a member of the fault-tolerant volume, but was unable to reassign the failing area of the device.
8101214pub const FT_READ_RECOVERY_FROM_BACKUP = 704;
1215
8111216/// {Redundant Write} To satisfy a write request, the NT fault-tolerant file system successfully wrote a redundant copy of the information. This was done because the file system encountered a failure on a member of the fault-tolerant volume, but was not able to reassign the failing area of the device.
8121217pub const FT_WRITE_RECOVERY = 705;
1218
8131219/// {Machine Type Mismatch} The image file %hs is valid, but is for a machine type other than the current machine. Select OK to continue, or CANCEL to fail the DLL load.
8141220pub const IMAGE_MACHINE_TYPE_MISMATCH = 706;
1221
8151222/// {Partial Data Received} The network transport returned partial data to its client. The remaining data will be sent later.
8161223pub const RECEIVE_PARTIAL = 707;
1224
8171225/// {Expedited Data Received} The network transport returned data to its client that was marked as expedited by the remote system.
8181226pub const RECEIVE_EXPEDITED = 708;
1227
8191228/// {Partial Expedited Data Received} The network transport returned partial data to its client and this data was marked as expedited by the remote system. The remaining data will be sent later.
8201229pub const RECEIVE_PARTIAL_EXPEDITED = 709;
1230
8211231/// {TDI Event Done} The TDI indication has completed successfully.
8221232pub const EVENT_DONE = 710;
1233
8231234/// {TDI Event Pending} The TDI indication has entered the pending state.
8241235pub const EVENT_PENDING = 711;
1236
8251237/// Checking file system on %wZ.
8261238pub const CHECKING_FILE_SYSTEM = 712;
1239
8271240/// {Fatal Application Exit} %hs.
8281241pub const FATAL_APP_EXIT = 713;
1242
8291243/// The specified registry key is referenced by a predefined handle.
8301244pub const PREDEFINED_HANDLE = 714;
1245
8311246/// {Page Unlocked} The page protection of a locked page was changed to 'No Access' and the page was unlocked from memory and from the process.
8321247pub const WAS_UNLOCKED = 715;
1248
8331249/// %hs
8341250pub const SERVICE_NOTIFICATION = 716;
1251
8351252/// {Page Locked} One of the pages to lock was already locked.
8361253pub const WAS_LOCKED = 717;
1254
8371255/// Application popup: %1 : %2
8381256pub const LOG_HARD_ERROR = 718;
1257
8391258/// ERROR_ALREADY_WIN32
8401259pub const ALREADY_WIN32 = 719;
1260
8411261/// {Machine Type Mismatch} The image file %hs is valid, but is for a machine type other than the current machine.
8421262pub const IMAGE_MACHINE_TYPE_MISMATCH_EXE = 720;
1263
8431264/// A yield execution was performed and no thread was available to run.
8441265pub const NO_YIELD_PERFORMED = 721;
1266
8451267/// The resumable flag to a timer API was ignored.
8461268pub const TIMER_RESUME_IGNORED = 722;
1269
8471270/// The arbiter has deferred arbitration of these resources to its parent.
8481271pub const ARBITRATION_UNHANDLED = 723;
1272
8491273/// The inserted CardBus device cannot be started because of a configuration error on "%hs".
8501274pub const CARDBUS_NOT_SUPPORTED = 724;
1275
8511276/// The CPUs in this multiprocessor system are not all the same revision level. To use all processors the operating system restricts itself to the features of the least capable processor in the system. Should problems occur with this system, contact the CPU manufacturer to see if this mix of processors is supported.
8521277pub const MP_PROCESSOR_MISMATCH = 725;
1278
8531279/// The system was put into hibernation.
8541280pub const HIBERNATED = 726;
1281
8551282/// The system was resumed from hibernation.
8561283pub const RESUME_HIBERNATION = 727;
1284
8571285/// Windows has detected that the system firmware (BIOS) was updated [previous firmware date = %2, current firmware date %3].
8581286pub const FIRMWARE_UPDATED = 728;
1287
8591288/// A device driver is leaking locked I/O pages causing system degradation. The system has automatically enabled tracking code in order to try and catch the culprit.
8601289pub const DRIVERS_LEAKING_LOCKED_PAGES = 729;
1290
8611291/// The system has awoken.
8621292pub const WAKE_SYSTEM = 730;
1293
8631294/// ERROR_WAIT_1
8641295pub const WAIT_1 = 731;
1296
8651297/// ERROR_WAIT_2
8661298pub const WAIT_2 = 732;
1299
8671300/// ERROR_WAIT_3
8681301pub const WAIT_3 = 733;
1302
8691303/// ERROR_WAIT_63
8701304pub const WAIT_63 = 734;
1305
8711306/// ERROR_ABANDONED_WAIT_0
8721307pub const ABANDONED_WAIT_0 = 735;
1308
8731309/// ERROR_ABANDONED_WAIT_63
8741310pub const ABANDONED_WAIT_63 = 736;
1311
8751312/// ERROR_USER_APC
8761313pub const USER_APC = 737;
1314
8771315/// ERROR_KERNEL_APC
8781316pub const KERNEL_APC = 738;
1317
8791318/// ERROR_ALERTED
8801319pub const ALERTED = 739;
1320
8811321/// The requested operation requires elevation.
8821322pub const ELEVATION_REQUIRED = 740;
1323
8831324/// A reparse should be performed by the Object Manager since the name of the file resulted in a symbolic link.
8841325pub const REPARSE = 741;
1326
8851327/// An open/create operation completed while an oplock break is underway.
8861328pub const OPLOCK_BREAK_IN_PROGRESS = 742;
1329
8871330/// A new volume has been mounted by a file system.
8881331pub const VOLUME_MOUNTED = 743;
1332
8891333/// This success level status indicates that the transaction state already exists for the registry sub-tree, but that a transaction commit was previously aborted. The commit has now been completed.
8901334pub const RXACT_COMMITTED = 744;
1335
8911336/// This indicates that a notify change request has been completed due to closing the handle which made the notify change request.
8921337pub const NOTIFY_CLEANUP = 745;
1338
8931339/// {Connect Failure on Primary Transport} An attempt was made to connect to the remote server %hs on the primary transport, but the connection failed. The computer WAS able to connect on a secondary transport.
8941340pub const PRIMARY_TRANSPORT_CONNECT_FAILED = 746;
1341
8951342/// Page fault was a transition fault.
8961343pub const PAGE_FAULT_TRANSITION = 747;
1344
8971345/// Page fault was a demand zero fault.
8981346pub const PAGE_FAULT_DEMAND_ZERO = 748;
1347
8991348/// Page fault was a demand zero fault.
9001349pub const PAGE_FAULT_COPY_ON_WRITE = 749;
1350
9011351/// Page fault was a demand zero fault.
9021352pub const PAGE_FAULT_GUARD_PAGE = 750;
1353
9031354/// Page fault was satisfied by reading from a secondary storage device.
9041355pub const PAGE_FAULT_PAGING_FILE = 751;
1356
9051357/// Cached page was locked during operation.
9061358pub const CACHE_PAGE_LOCKED = 752;
1359
9071360/// Crash dump exists in paging file.
9081361pub const CRASH_DUMP = 753;
1362
9091363/// Specified buffer contains all zeros.
9101364pub const BUFFER_ALL_ZEROS = 754;
1365
9111366/// A reparse should be performed by the Object Manager since the name of the file resulted in a symbolic link.
9121367pub const REPARSE_OBJECT = 755;
1368
9131369/// The device has succeeded a query-stop and its resource requirements have changed.
9141370pub const RESOURCE_REQUIREMENTS_CHANGED = 756;
1371
9151372/// The translator has translated these resources into the global space and no further translations should be performed.
9161373pub const TRANSLATION_COMPLETE = 757;
1374
9171375/// A process being terminated has no threads to terminate.
9181376pub const NOTHING_TO_TERMINATE = 758;
1377
9191378/// The specified process is not part of a job.
9201379pub const PROCESS_NOT_IN_JOB = 759;
1380
9211381/// The specified process is part of a job.
9221382pub const PROCESS_IN_JOB = 760;
1383
9231384/// {Volume Shadow Copy Service} The system is now ready for hibernation.
9241385pub const VOLSNAP_HIBERNATE_READY = 761;
1386
9251387/// A file system or file system filter driver has successfully completed an FsFilter operation.
9261388pub const FSFILTER_OP_COMPLETED_SUCCESSFULLY = 762;
1389
9271390/// The specified interrupt vector was already connected.
9281391pub const INTERRUPT_VECTOR_ALREADY_CONNECTED = 763;
1392
9291393/// The specified interrupt vector is still connected.
9301394pub const INTERRUPT_STILL_CONNECTED = 764;
1395
9311396/// An operation is blocked waiting for an oplock.
9321397pub const WAIT_FOR_OPLOCK = 765;
1398
9331399/// Debugger handled exception.
9341400pub const DBG_EXCEPTION_HANDLED = 766;
1401
9351402/// Debugger continued.
9361403pub const DBG_CONTINUE = 767;
1404
9371405/// An exception occurred in a user mode callback and the kernel callback frame should be removed.
9381406pub const CALLBACK_POP_STACK = 768;
1407
9391408/// Compression is disabled for this volume.
9401409pub const COMPRESSION_DISABLED = 769;
1410
9411411/// The data provider cannot fetch backwards through a result set.
9421412pub const CANTFETCHBACKWARDS = 770;
1413
9431414/// The data provider cannot scroll backwards through a result set.
9441415pub const CANTSCROLLBACKWARDS = 771;
1416
9451417/// The data provider requires that previously fetched data is released before asking for more data.
9461418pub const ROWSNOTRELEASED = 772;
1419
9471420/// The data provider was not able to interpret the flags set for a column binding in an accessor.
9481421pub const BAD_ACCESSOR_FLAGS = 773;
1422
9491423/// One or more errors occurred while processing the request.
9501424pub const ERRORS_ENCOUNTERED = 774;
1425
9511426/// The implementation is not capable of performing the request.
9521427pub const NOT_CAPABLE = 775;
1428
9531429/// The client of a component requested an operation which is not valid given the state of the component instance.
9541430pub const REQUEST_OUT_OF_SEQUENCE = 776;
1431
9551432/// A version number could not be parsed.
9561433pub const VERSION_PARSE_ERROR = 777;
1434
9571435/// The iterator's start position is invalid.
9581436pub const BADSTARTPOSITION = 778;
1437
9591438/// The hardware has reported an uncorrectable memory error.
9601439pub const MEMORY_HARDWARE = 779;
1440
9611441/// The attempted operation required self healing to be enabled.
9621442pub const DISK_REPAIR_DISABLED = 780;
1443
9631444/// The Desktop heap encountered an error while allocating session memory. There is more information in the system event log.
9641445pub const INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE = 781;
1446
9651447/// The system power state is transitioning from %2 to %3.
9661448pub const SYSTEM_POWERSTATE_TRANSITION = 782;
1449
9671450/// The system power state is transitioning from %2 to %3 but could enter %4.
9681451pub const SYSTEM_POWERSTATE_COMPLEX_TRANSITION = 783;
1452
9691453/// A thread is getting dispatched with MCA EXCEPTION because of MCA.
9701454pub const MCA_EXCEPTION = 784;
1455
9711456/// Access to %1 is monitored by policy rule %2.
9721457pub const ACCESS_AUDIT_BY_POLICY = 785;
1458
9731459/// Access to %1 has been restricted by your Administrator by policy rule %2.
9741460pub const ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY = 786;
1461
9751462/// A valid hibernation file has been invalidated and should be abandoned.
9761463pub const ABANDON_HIBERFILE = 787;
1464
9771465/// {Delayed Write Failed} Windows was unable to save all the data for the file %hs; the data has been lost. This error may be caused by network connectivity issues. Please try to save this file elsewhere.
9781466pub const LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED = 788;
1467
9791468/// {Delayed Write Failed} Windows was unable to save all the data for the file %hs; the data has been lost. This error was returned by the server on which the file exists. Please try to save this file elsewhere.
9801469pub const LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR = 789;
1470
9811471/// {Delayed Write Failed} Windows was unable to save all the data for the file %hs; the data has been lost. This error may be caused if the device has been removed or the media is write-protected.
9821472pub const LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR = 790;
1473
9831474/// The resources required for this device conflict with the MCFG table.
9841475pub const BAD_MCFG_TABLE = 791;
1476
9851477/// The volume repair could not be performed while it is online. Please schedule to take the volume offline so that it can be repaired.
9861478pub const DISK_REPAIR_REDIRECTED = 792;
1479
9871480/// The volume repair was not successful.
9881481pub const DISK_REPAIR_UNSUCCESSFUL = 793;
1482
9891483/// One of the volume corruption logs is full. Further corruptions that may be detected won't be logged.
9901484pub const CORRUPT_LOG_OVERFULL = 794;
1485
9911486/// One of the volume corruption logs is internally corrupted and needs to be recreated. The volume may contain undetected corruptions and must be scanned.
9921487pub const CORRUPT_LOG_CORRUPTED = 795;
1488
9931489/// One of the volume corruption logs is unavailable for being operated on.
9941490pub const CORRUPT_LOG_UNAVAILABLE = 796;
1491
9951492/// One of the volume corruption logs was deleted while still having corruption records in them. The volume contains detected corruptions and must be scanned.
9961493pub const CORRUPT_LOG_DELETED_FULL = 797;
1494
9971495/// One of the volume corruption logs was cleared by chkdsk and no longer contains real corruptions.
9981496pub const CORRUPT_LOG_CLEARED = 798;
1497
9991498/// Orphaned files exist on the volume but could not be recovered because no more new names could be created in the recovery directory. Files must be moved from the recovery directory.
10001499pub const ORPHAN_NAME_EXHAUSTED = 799;
1500
10011501/// The oplock that was associated with this handle is now associated with a different handle.
10021502pub const OPLOCK_SWITCHED_TO_NEW_HANDLE = 800;
1503
10031504/// An oplock of the requested level cannot be granted. An oplock of a lower level may be available.
10041505pub const CANNOT_GRANT_REQUESTED_OPLOCK = 801;
1506
10051507/// The operation did not complete successfully because it would cause an oplock to be broken. The caller has requested that existing oplocks not be broken.
10061508pub const CANNOT_BREAK_OPLOCK = 802;
1509
10071510/// The handle with which this oplock was associated has been closed. The oplock is now broken.
10081511pub const OPLOCK_HANDLE_CLOSED = 803;
1512
10091513/// The specified access control entry (ACE) does not contain a condition.
10101514pub const NO_ACE_CONDITION = 804;
1515
10111516/// The specified access control entry (ACE) contains an invalid condition.
10121517pub const INVALID_ACE_CONDITION = 805;
1518
10131519/// Access to the specified file handle has been revoked.
10141520pub const FILE_HANDLE_REVOKED = 806;
1521
10151522/// An image file was mapped at a different address from the one specified in the image file but fixups will still be automatically performed on the image.
10161523pub const IMAGE_AT_DIFFERENT_BASE = 807;
1524
10171525/// Access to the extended attribute was denied.
10181526pub const EA_ACCESS_DENIED = 994;
1527
10191528/// The I/O operation has been aborted because of either a thread exit or an application request.
10201529pub const OPERATION_ABORTED = 995;
1530
10211531/// Overlapped I/O event is not in a signaled state.
10221532pub const IO_INCOMPLETE = 996;
1533
10231534/// Overlapped I/O operation is in progress.
10241535pub const IO_PENDING = 997;
1536
10251537/// Invalid access to memory location.
10261538pub const NOACCESS = 998;
1539
10271540/// Error performing inpage operation.
10281541pub const SWAPERROR = 999;
1542
10291543/// Recursion too deep; the stack overflowed.
10301544pub const STACK_OVERFLOW = 1001;
1545
10311546/// The window cannot act on the sent message.
10321547pub const INVALID_MESSAGE = 1002;
1548
10331549/// Cannot complete this function.
10341550pub const CAN_NOT_COMPLETE = 1003;
1551
10351552/// Invalid flags.
10361553pub const INVALID_FLAGS = 1004;
1554
10371555/// The volume does not contain a recognized file system. Please make sure that all required file system drivers are loaded and that the volume is not corrupted.
10381556pub const UNRECOGNIZED_VOLUME = 1005;
1557
10391558/// The volume for a file has been externally altered so that the opened file is no longer valid.
10401559pub const FILE_INVALID = 1006;
1560
10411561/// The requested operation cannot be performed in full-screen mode.
10421562pub const FULLSCREEN_MODE = 1007;
1563
10431564/// An attempt was made to reference a token that does not exist.
10441565pub const NO_TOKEN = 1008;
1566
10451567/// The configuration registry database is corrupt.
10461568pub const BADDB = 1009;
1569
10471570/// The configuration registry key is invalid.
10481571pub const BADKEY = 1010;
1572
10491573/// The configuration registry key could not be opened.
10501574pub const CANTOPEN = 1011;
1575
10511576/// The configuration registry key could not be read.
10521577pub const CANTREAD = 1012;
1578
10531579/// The configuration registry key could not be written.
10541580pub const CANTWRITE = 1013;
1581
10551582/// One of the files in the registry database had to be recovered by use of a log or alternate copy. The recovery was successful.
10561583pub const REGISTRY_RECOVERED = 1014;
1584
10571585/// The registry is corrupted. The structure of one of the files containing registry data is corrupted, or the system's memory image of the file is corrupted, or the file could not be recovered because the alternate copy or log was absent or corrupted.
10581586pub const REGISTRY_CORRUPT = 1015;
1587
10591588/// An I/O operation initiated by the registry failed unrecoverably. The registry could not read in, or write out, or flush, one of the files that contain the system's image of the registry.
10601589pub const REGISTRY_IO_FAILED = 1016;
1590
10611591/// The system has attempted to load or restore a file into the registry, but the specified file is not in a registry file format.
10621592pub const NOT_REGISTRY_FILE = 1017;
1593
10631594/// Illegal operation attempted on a registry key that has been marked for deletion.
10641595pub const KEY_DELETED = 1018;
1596
10651597/// System could not allocate the required space in a registry log.
10661598pub const NO_LOG_SPACE = 1019;
1599
10671600/// Cannot create a symbolic link in a registry key that already has subkeys or values.
10681601pub const KEY_HAS_CHILDREN = 1020;
1602
10691603/// Cannot create a stable subkey under a volatile parent key.
10701604pub const CHILD_MUST_BE_VOLATILE = 1021;
1605
10711606/// A notify change request is being completed and the information is not being returned in the caller's buffer. The caller now needs to enumerate the files to find the changes.
10721607pub const NOTIFY_ENUM_DIR = 1022;
1608
10731609/// A stop control has been sent to a service that other running services are dependent on.
10741610pub const DEPENDENT_SERVICES_RUNNING = 1051;
1611
10751612/// The requested control is not valid for this service.
10761613pub const INVALID_SERVICE_CONTROL = 1052;
1614
10771615/// The service did not respond to the start or control request in a timely fashion.
10781616pub const SERVICE_REQUEST_TIMEOUT = 1053;
1617
10791618/// A thread could not be created for the service.
10801619pub const SERVICE_NO_THREAD = 1054;
1620
10811621/// The service database is locked.
10821622pub const SERVICE_DATABASE_LOCKED = 1055;
1623
10831624/// An instance of the service is already running.
10841625pub const SERVICE_ALREADY_RUNNING = 1056;
1626
10851627/// The account name is invalid or does not exist, or the password is invalid for the account name specified.
10861628pub const INVALID_SERVICE_ACCOUNT = 1057;
1629
10871630/// The service cannot be started, either because it is disabled or because it has no enabled devices associated with it.
10881631pub const SERVICE_DISABLED = 1058;
1632
10891633/// Circular service dependency was specified.
10901634pub const CIRCULAR_DEPENDENCY = 1059;
1635
10911636/// The specified service does not exist as an installed service.
10921637pub const SERVICE_DOES_NOT_EXIST = 1060;
1638
10931639/// The service cannot accept control messages at this time.
10941640pub const SERVICE_CANNOT_ACCEPT_CTRL = 1061;
1641
10951642/// The service has not been started.
10961643pub const SERVICE_NOT_ACTIVE = 1062;
1644
10971645/// The service process could not connect to the service controller.
10981646pub const FAILED_SERVICE_CONTROLLER_CONNECT = 1063;
1647
10991648/// An exception occurred in the service when handling the control request.
11001649pub const EXCEPTION_IN_SERVICE = 1064;
1650
11011651/// The database specified does not exist.
11021652pub const DATABASE_DOES_NOT_EXIST = 1065;
1653
11031654/// The service has returned a service-specific error code.
11041655pub const SERVICE_SPECIFIC_ERROR = 1066;
1656
11051657/// The process terminated unexpectedly.
11061658pub const PROCESS_ABORTED = 1067;
1659
11071660/// The dependency service or group failed to start.
11081661pub const SERVICE_DEPENDENCY_FAIL = 1068;
1662
11091663/// The service did not start due to a logon failure.
11101664pub const SERVICE_LOGON_FAILED = 1069;
1665
11111666/// After starting, the service hung in a start-pending state.
11121667pub const SERVICE_START_HANG = 1070;
1668
11131669/// The specified service database lock is invalid.
11141670pub const INVALID_SERVICE_LOCK = 1071;
1671
11151672/// The specified service has been marked for deletion.
11161673pub const SERVICE_MARKED_FOR_DELETE = 1072;
1674
11171675/// The specified service already exists.
11181676pub const SERVICE_EXISTS = 1073;
1677
11191678/// The system is currently running with the last-known-good configuration.
11201679pub const ALREADY_RUNNING_LKG = 1074;
1680
11211681/// The dependency service does not exist or has been marked for deletion.
11221682pub const SERVICE_DEPENDENCY_DELETED = 1075;
1683
11231684/// The current boot has already been accepted for use as the last-known-good control set.
11241685pub const BOOT_ALREADY_ACCEPTED = 1076;
1686
11251687/// No attempts to start the service have been made since the last boot.
11261688pub const SERVICE_NEVER_STARTED = 1077;
1689
11271690/// The name is already in use as either a service name or a service display name.
11281691pub const DUPLICATE_SERVICE_NAME = 1078;
1692
11291693/// The account specified for this service is different from the account specified for other services running in the same process.
11301694pub const DIFFERENT_SERVICE_ACCOUNT = 1079;
1695
11311696/// Failure actions can only be set for Win32 services, not for drivers.
11321697pub const CANNOT_DETECT_DRIVER_FAILURE = 1080;
1698
11331699/// This service runs in the same process as the service control manager. Therefore, the service control manager cannot take action if this service's process terminates unexpectedly.
11341700pub const CANNOT_DETECT_PROCESS_ABORT = 1081;
1701
11351702/// No recovery program has been configured for this service.
11361703pub const NO_RECOVERY_PROGRAM = 1082;
1704
11371705/// The executable program that this service is configured to run in does not implement the service.
11381706pub const SERVICE_NOT_IN_EXE = 1083;
1707
11391708/// This service cannot be started in Safe Mode.
11401709pub const NOT_SAFEBOOT_SERVICE = 1084;
1710
11411711/// The physical end of the tape has been reached.
11421712pub const END_OF_MEDIA = 1100;
1713
11431714/// A tape access reached a filemark.
11441715pub const FILEMARK_DETECTED = 1101;
1716
11451717/// The beginning of the tape or a partition was encountered.
11461718pub const BEGINNING_OF_MEDIA = 1102;
1719
11471720/// A tape access reached the end of a set of files.
11481721pub const SETMARK_DETECTED = 1103;
1722
11491723/// No more data is on the tape.
11501724pub const NO_DATA_DETECTED = 1104;
1725
11511726/// Tape could not be partitioned.
11521727pub const PARTITION_FAILURE = 1105;
1728
11531729/// When accessing a new tape of a multivolume partition, the current block size is incorrect.
11541730pub const INVALID_BLOCK_LENGTH = 1106;
1731
11551732/// Tape partition information could not be found when loading a tape.
11561733pub const DEVICE_NOT_PARTITIONED = 1107;
1734
11571735/// Unable to lock the media eject mechanism.
11581736pub const UNABLE_TO_LOCK_MEDIA = 1108;
1737
11591738/// Unable to unload the media.
11601739pub const UNABLE_TO_UNLOAD_MEDIA = 1109;
1740
11611741/// The media in the drive may have changed.
11621742pub const MEDIA_CHANGED = 1110;
1743
11631744/// The I/O bus was reset.
11641745pub const BUS_RESET = 1111;
1746
11651747/// No media in drive.
11661748pub const NO_MEDIA_IN_DRIVE = 1112;
1749
11671750/// No mapping for the Unicode character exists in the target multi-byte code page.
11681751pub const NO_UNICODE_TRANSLATION = 1113;
1752
11691753/// A dynamic link library (DLL) initialization routine failed.
11701754pub const DLL_INIT_FAILED = 1114;
1755
11711756/// A system shutdown is in progress.
11721757pub const SHUTDOWN_IN_PROGRESS = 1115;
1758
11731759/// Unable to abort the system shutdown because no shutdown was in progress.
11741760pub const NO_SHUTDOWN_IN_PROGRESS = 1116;
1761
11751762/// The request could not be performed because of an I/O device error.
11761763pub const IO_DEVICE = 1117;
1764
11771765/// No serial device was successfully initialized. The serial driver will unload.
11781766pub const SERIAL_NO_DEVICE = 1118;
1767
11791768/// Unable to open a device that was sharing an interrupt request (IRQ) with other devices. At least one other device that uses that IRQ was already opened.
11801769pub const IRQ_BUSY = 1119;
1770
11811771/// A serial I/O operation was completed by another write to the serial port. The IOCTL_SERIAL_XOFF_COUNTER reached zero.)
11821772pub const MORE_WRITES = 1120;
1773
11831774/// A serial I/O operation completed because the timeout period expired. The IOCTL_SERIAL_XOFF_COUNTER did not reach zero.)
11841775pub const COUNTER_TIMEOUT = 1121;
1776
11851777/// No ID address mark was found on the floppy disk.
11861778pub const FLOPPY_ID_MARK_NOT_FOUND = 1122;
1779
11871780/// Mismatch between the floppy disk sector ID field and the floppy disk controller track address.
11881781pub const FLOPPY_WRONG_CYLINDER = 1123;
1782
11891783/// The floppy disk controller reported an error that is not recognized by the floppy disk driver.
11901784pub const FLOPPY_UNKNOWN_ERROR = 1124;
1785
11911786/// The floppy disk controller returned inconsistent results in its registers.
11921787pub const FLOPPY_BAD_REGISTERS = 1125;
1788
11931789/// While accessing the hard disk, a recalibrate operation failed, even after retries.
11941790pub const DISK_RECALIBRATE_FAILED = 1126;
1791
11951792/// While accessing the hard disk, a disk operation failed even after retries.
11961793pub const DISK_OPERATION_FAILED = 1127;
1794
11971795/// While accessing the hard disk, a disk controller reset was needed, but even that failed.
11981796pub const DISK_RESET_FAILED = 1128;
1797
11991798/// Physical end of tape encountered.
12001799pub const EOM_OVERFLOW = 1129;
1800
12011801/// Not enough server storage is available to process this command.
12021802pub const NOT_ENOUGH_SERVER_MEMORY = 1130;
1803
12031804/// A potential deadlock condition has been detected.
12041805pub const POSSIBLE_DEADLOCK = 1131;
1806
12051807/// The base address or the file offset specified does not have the proper alignment.
12061808pub const MAPPED_ALIGNMENT = 1132;
1809
12071810/// An attempt to change the system power state was vetoed by another application or driver.
12081811pub const SET_POWER_STATE_VETOED = 1140;
1812
12091813/// The system BIOS failed an attempt to change the system power state.
12101814pub const SET_POWER_STATE_FAILED = 1141;
1815
12111816/// An attempt was made to create more links on a file than the file system supports.
12121817pub const TOO_MANY_LINKS = 1142;
1818
12131819/// The specified program requires a newer version of Windows.
12141820pub const OLD_WIN_VERSION = 1150;
1821
12151822/// The specified program is not a Windows or MS-DOS program.
12161823pub const APP_WRONG_OS = 1151;
1824
12171825/// Cannot start more than one instance of the specified program.
12181826pub const SINGLE_INSTANCE_APP = 1152;
1827
12191828/// The specified program was written for an earlier version of Windows.
12201829pub const RMODE_APP = 1153;
1830
12211831/// One of the library files needed to run this application is damaged.
12221832pub const INVALID_DLL = 1154;
1833
12231834/// No application is associated with the specified file for this operation.
12241835pub const NO_ASSOCIATION = 1155;
1836
12251837/// An error occurred in sending the command to the application.
12261838pub const DDE_FAIL = 1156;
1839
12271840/// One of the library files needed to run this application cannot be found.
12281841pub const DLL_NOT_FOUND = 1157;
1842
12291843/// The current process has used all of its system allowance of handles for Window Manager objects.
12301844pub const NO_MORE_USER_HANDLES = 1158;
1845
12311846/// The message can be used only with synchronous operations.
12321847pub const MESSAGE_SYNC_ONLY = 1159;
1848
12331849/// The indicated source element has no media.
12341850pub const SOURCE_ELEMENT_EMPTY = 1160;
1851
12351852/// The indicated destination element already contains media.
12361853pub const DESTINATION_ELEMENT_FULL = 1161;
1854
12371855/// The indicated element does not exist.
12381856pub const ILLEGAL_ELEMENT_ADDRESS = 1162;
1857
12391858/// The indicated element is part of a magazine that is not present.
12401859pub const MAGAZINE_NOT_PRESENT = 1163;
1860
12411861/// The indicated device requires reinitialization due to hardware errors.
12421862pub const DEVICE_REINITIALIZATION_NEEDED = 1164;
1863
12431864/// The device has indicated that cleaning is required before further operations are attempted.
12441865pub const DEVICE_REQUIRES_CLEANING = 1165;
1866
12451867/// The device has indicated that its door is open.
12461868pub const DEVICE_DOOR_OPEN = 1166;
1869
12471870/// The device is not connected.
12481871pub const DEVICE_NOT_CONNECTED = 1167;
1872
12491873/// Element not found.
12501874pub const NOT_FOUND = 1168;
1875
12511876/// There was no match for the specified key in the index.
12521877pub const NO_MATCH = 1169;
1878
12531879/// The property set specified does not exist on the object.
12541880pub const SET_NOT_FOUND = 1170;
1881
12551882/// The point passed to GetMouseMovePoints is not in the buffer.
12561883pub const POINT_NOT_FOUND = 1171;
1884
12571885/// The tracking (workstation) service is not running.
12581886pub const NO_TRACKING_SERVICE = 1172;
1887
12591888/// The Volume ID could not be found.
12601889pub const NO_VOLUME_ID = 1173;
1890
12611891/// Unable to remove the file to be replaced.
12621892pub const UNABLE_TO_REMOVE_REPLACED = 1175;
1893
12631894/// Unable to move the replacement file to the file to be replaced. The file to be replaced has retained its original name.
12641895pub const UNABLE_TO_MOVE_REPLACEMENT = 1176;
1896
12651897/// Unable to move the replacement file to the file to be replaced. The file to be replaced has been renamed using the backup name.
12661898pub const UNABLE_TO_MOVE_REPLACEMENT_2 = 1177;
1899
12671900/// The volume change journal is being deleted.
12681901pub const JOURNAL_DELETE_IN_PROGRESS = 1178;
1902
12691903/// The volume change journal is not active.
12701904pub const JOURNAL_NOT_ACTIVE = 1179;
1905
12711906/// A file was found, but it may not be the correct file.
12721907pub const POTENTIAL_FILE_FOUND = 1180;
1908
12731909/// The journal entry has been deleted from the journal.
12741910pub const JOURNAL_ENTRY_DELETED = 1181;
1911
12751912/// A system shutdown has already been scheduled.
12761913pub const SHUTDOWN_IS_SCHEDULED = 1190;
1914
12771915/// The system shutdown cannot be initiated because there are other users logged on to the computer.
12781916pub const SHUTDOWN_USERS_LOGGED_ON = 1191;
1917
12791918/// The specified device name is invalid.
12801919pub const BAD_DEVICE = 1200;
1920
12811921/// The device is not currently connected but it is a remembered connection.
12821922pub const CONNECTION_UNAVAIL = 1201;
1923
12831924/// The local device name has a remembered connection to another network resource.
12841925pub const DEVICE_ALREADY_REMEMBERED = 1202;
1926
12851927/// The network path was either typed incorrectly, does not exist, or the network provider is not currently available. Please try retyping the path or contact your network administrator.
12861928pub const NO_NET_OR_BAD_PATH = 1203;
1929
12871930/// The specified network provider name is invalid.
12881931pub const BAD_PROVIDER = 1204;
1932
12891933/// Unable to open the network connection profile.
12901934pub const CANNOT_OPEN_PROFILE = 1205;
1935
12911936/// The network connection profile is corrupted.
12921937pub const BAD_PROFILE = 1206;
1938
12931939/// Cannot enumerate a noncontainer.
12941940pub const NOT_CONTAINER = 1207;
1941
12951942/// An extended error has occurred.
12961943pub const EXTENDED_ERROR = 1208;
1944
12971945/// The format of the specified group name is invalid.
12981946pub const INVALID_GROUPNAME = 1209;
1947
12991948/// The format of the specified computer name is invalid.
13001949pub const INVALID_COMPUTERNAME = 1210;
1950
13011951/// The format of the specified event name is invalid.
13021952pub const INVALID_EVENTNAME = 1211;
1953
13031954/// The format of the specified domain name is invalid.
13041955pub const INVALID_DOMAINNAME = 1212;
1956
13051957/// The format of the specified service name is invalid.
13061958pub const INVALID_SERVICENAME = 1213;
1959
13071960/// The format of the specified network name is invalid.
13081961pub const INVALID_NETNAME = 1214;
1962
13091963/// The format of the specified share name is invalid.
13101964pub const INVALID_SHARENAME = 1215;
1965
13111966/// The format of the specified password is invalid.
13121967pub const INVALID_PASSWORDNAME = 1216;
1968
13131969/// The format of the specified message name is invalid.
13141970pub const INVALID_MESSAGENAME = 1217;
1971
13151972/// The format of the specified message destination is invalid.
13161973pub const INVALID_MESSAGEDEST = 1218;
1974
13171975/// Multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed. Disconnect all previous connections to the server or shared resource and try again.
13181976pub const SESSION_CREDENTIAL_CONFLICT = 1219;
1977
13191978/// An attempt was made to establish a session to a network server, but there are already too many sessions established to that server.
13201979pub const REMOTE_SESSION_LIMIT_EXCEEDED = 1220;
1980
13211981/// The workgroup or domain name is already in use by another computer on the network.
13221982pub const DUP_DOMAINNAME = 1221;
1983
13231984/// The network is not present or not started.
13241985pub const NO_NETWORK = 1222;
1986
13251987/// The operation was canceled by the user.
13261988pub const CANCELLED = 1223;
1989
13271990/// The requested operation cannot be performed on a file with a user-mapped section open.
13281991pub const USER_MAPPED_FILE = 1224;
1992
13291993/// The remote computer refused the network connection.
13301994pub const CONNECTION_REFUSED = 1225;
1995
13311996/// The network connection was gracefully closed.
13321997pub const GRACEFUL_DISCONNECT = 1226;
1998
13331999/// The network transport endpoint already has an address associated with it.
13342000pub const ADDRESS_ALREADY_ASSOCIATED = 1227;
2001
13352002/// An address has not yet been associated with the network endpoint.
13362003pub const ADDRESS_NOT_ASSOCIATED = 1228;
2004
13372005/// An operation was attempted on a nonexistent network connection.
13382006pub const CONNECTION_INVALID = 1229;
2007
13392008/// An invalid operation was attempted on an active network connection.
13402009pub const CONNECTION_ACTIVE = 1230;
2010
13412011/// The network location cannot be reached. For information about network troubleshooting, see Windows Help.
13422012pub const NETWORK_UNREACHABLE = 1231;
2013
13432014/// The network location cannot be reached. For information about network troubleshooting, see Windows Help.
13442015pub const HOST_UNREACHABLE = 1232;
2016
13452017/// The network location cannot be reached. For information about network troubleshooting, see Windows Help.
13462018pub const PROTOCOL_UNREACHABLE = 1233;
2019
13472020/// No service is operating at the destination network endpoint on the remote system.
13482021pub const PORT_UNREACHABLE = 1234;
2022
13492023/// The request was aborted.
13502024pub const REQUEST_ABORTED = 1235;
2025
13512026/// The network connection was aborted by the local system.
13522027pub const CONNECTION_ABORTED = 1236;
2028
13532029/// The operation could not be completed. A retry should be performed.
13542030pub const RETRY = 1237;
2031
13552032/// A connection to the server could not be made because the limit on the number of concurrent connections for this account has been reached.
13562033pub const CONNECTION_COUNT_LIMIT = 1238;
2034
13572035/// Attempting to log in during an unauthorized time of day for this account.
13582036pub const LOGIN_TIME_RESTRICTION = 1239;
2037
13592038/// The account is not authorized to log in from this station.
13602039pub const LOGIN_WKSTA_RESTRICTION = 1240;
2040
13612041/// The network address could not be used for the operation requested.
13622042pub const INCORRECT_ADDRESS = 1241;
2043
13632044/// The service is already registered.
13642045pub const ALREADY_REGISTERED = 1242;
2046
13652047/// The specified service does not exist.
13662048pub const SERVICE_NOT_FOUND = 1243;
2049
13672050/// The operation being requested was not performed because the user has not been authenticated.
13682051pub const NOT_AUTHENTICATED = 1244;
2052
13692053/// The operation being requested was not performed because the user has not logged on to the network. The specified service does not exist.
13702054pub const NOT_LOGGED_ON = 1245;
2055
13712056/// Continue with work in progress.
13722057pub const CONTINUE = 1246;
2058
13732059/// An attempt was made to perform an initialization operation when initialization has already been completed.
13742060pub const ALREADY_INITIALIZED = 1247;
2061
13752062/// No more local devices.
13762063pub const NO_MORE_DEVICES = 1248;
2064
13772065/// The specified site does not exist.
13782066pub const NO_SUCH_SITE = 1249;
2067
13792068/// A domain controller with the specified name already exists.
13802069pub const DOMAIN_CONTROLLER_EXISTS = 1250;
2070
13812071/// This operation is supported only when you are connected to the server.
13822072pub const ONLY_IF_CONNECTED = 1251;
2073
13832074/// The group policy framework should call the extension even if there are no changes.
13842075pub const OVERRIDE_NOCHANGES = 1252;
2076
13852077/// The specified user does not have a valid profile.
13862078pub const BAD_USER_PROFILE = 1253;
2079
13872080/// This operation is not supported on a computer running Windows Server 2003 for Small Business Server.
13882081pub const NOT_SUPPORTED_ON_SBS = 1254;
2082
13892083/// The server machine is shutting down.
13902084pub const SERVER_SHUTDOWN_IN_PROGRESS = 1255;
2085
13912086/// The remote system is not available. For information about network troubleshooting, see Windows Help.
13922087pub const HOST_DOWN = 1256;
2088
13932089/// The security identifier provided is not from an account domain.
13942090pub const NON_ACCOUNT_SID = 1257;
2091
13952092/// The security identifier provided does not have a domain component.
13962093pub const NON_DOMAIN_SID = 1258;
2094
13972095/// AppHelp dialog canceled thus preventing the application from starting.
13982096pub const APPHELP_BLOCK = 1259;
2097
13992098/// This program is blocked by group policy. For more information, contact your system administrator.
14002099pub const ACCESS_DISABLED_BY_POLICY = 1260;
2100
14012101/// A program attempt to use an invalid register value. Normally caused by an uninitialized register. This error is Itanium specific.
14022102pub const REG_NAT_CONSUMPTION = 1261;
2103
14032104/// The share is currently offline or does not exist.
14042105pub const CSCSHARE_OFFLINE = 1262;
2106
14052107/// The Kerberos protocol encountered an error while validating the KDC certificate during smartcard logon. There is more information in the system event log.
14062108pub const PKINIT_FAILURE = 1263;
2109
14072110/// The Kerberos protocol encountered an error while attempting to utilize the smartcard subsystem.
14082111pub const SMARTCARD_SUBSYSTEM_FAILURE = 1264;
2112
14092113/// The system cannot contact a domain controller to service the authentication request. Please try again later.
14102114pub const DOWNGRADE_DETECTED = 1265;
2115
14112116/// The machine is locked and cannot be shut down without the force option.
14122117pub const MACHINE_LOCKED = 1271;
2118
14132119/// An application-defined callback gave invalid data when called.
14142120pub const CALLBACK_SUPPLIED_INVALID_DATA = 1273;
2121
14152122/// The group policy framework should call the extension in the synchronous foreground policy refresh.
14162123pub const SYNC_FOREGROUND_REFRESH_REQUIRED = 1274;
2124
14172125/// This driver has been blocked from loading.
14182126pub const DRIVER_BLOCKED = 1275;
2127
14192128/// A dynamic link library (DLL) referenced a module that was neither a DLL nor the process's executable image.
14202129pub const INVALID_IMPORT_OF_NON_DLL = 1276;
2130
14212131/// Windows cannot open this program since it has been disabled.
14222132pub const ACCESS_DISABLED_WEBBLADE = 1277;
2133
14232134/// Windows cannot open this program because the license enforcement system has been tampered with or become corrupted.
14242135pub const ACCESS_DISABLED_WEBBLADE_TAMPER = 1278;
2136
14252137/// A transaction recover failed.
14262138pub const RECOVERY_FAILURE = 1279;
2139
14272140/// The current thread has already been converted to a fiber.
14282141pub const ALREADY_FIBER = 1280;
2142
14292143/// The current thread has already been converted from a fiber.
14302144pub const ALREADY_THREAD = 1281;
2145
14312146/// The system detected an overrun of a stack-based buffer in this application. This overrun could potentially allow a malicious user to gain control of this application.
14322147pub const STACK_BUFFER_OVERRUN = 1282;
2148
14332149/// Data present in one of the parameters is more than the function can operate on.
14342150pub const PARAMETER_QUOTA_EXCEEDED = 1283;
2151
14352152/// An attempt to do an operation on a debug object failed because the object is in the process of being deleted.
14362153pub const DEBUGGER_INACTIVE = 1284;
2154
14372155/// An attempt to delay-load a .dll or get a function address in a delay-loaded .dll failed.
14382156pub const DELAY_LOAD_FAILED = 1285;
2157
14392158/// %1 is a 16-bit application. You do not have permissions to execute 16-bit applications. Check your permissions with your system administrator.
14402159pub const VDM_DISALLOWED = 1286;
2160
14412161/// Insufficient information exists to identify the cause of failure.
14422162pub const UNIDENTIFIED_ERROR = 1287;
2163
14432164/// The parameter passed to a C runtime function is incorrect.
14442165pub const INVALID_CRUNTIME_PARAMETER = 1288;
2166
14452167/// The operation occurred beyond the valid data length of the file.
14462168pub const BEYOND_VDL = 1289;
2169
14472170/// The service start failed since one or more services in the same process have an incompatible service SID type setting. A service with restricted service SID type can only coexist in the same process with other services with a restricted SID type. If the service SID type for this service was just configured, the hosting process must be restarted in order to start this service.
14482171/// On Windows Server 2003 and Windows XP, an unrestricted service cannot coexist in the same process with other services. The service with the unrestricted service SID type must be moved to an owned process in order to start this service.
14492172pub const INCOMPATIBLE_SERVICE_SID_TYPE = 1290;
2173
14502174/// The process hosting the driver for this device has been terminated.
14512175pub const DRIVER_PROCESS_TERMINATED = 1291;
2176
14522177/// An operation attempted to exceed an implementation-defined limit.
14532178pub const IMPLEMENTATION_LIMIT = 1292;
2179
14542180/// Either the target process, or the target thread's containing process, is a protected process.
14552181pub const PROCESS_IS_PROTECTED = 1293;
2182
14562183/// The service notification client is lagging too far behind the current state of services in the machine.
14572184pub const SERVICE_NOTIFY_CLIENT_LAGGING = 1294;
2185
14582186/// The requested file operation failed because the storage quota was exceeded. To free up disk space, move files to a different location or delete unnecessary files. For more information, contact your system administrator.
14592187pub const DISK_QUOTA_EXCEEDED = 1295;
2188
14602189/// The requested file operation failed because the storage policy blocks that type of file. For more information, contact your system administrator.
14612190pub const CONTENT_BLOCKED = 1296;
2191
14622192/// A privilege that the service requires to function properly does not exist in the service account configuration. You may use the Services Microsoft Management Console (MMC) snap-in (services.msc) and the Local Security Settings MMC snap-in (secpol.msc) to view the service configuration and the account configuration.
14632193pub const INCOMPATIBLE_SERVICE_PRIVILEGE = 1297;
2194
14642195/// A thread involved in this operation appears to be unresponsive.
14652196pub const APP_HANG = 1298;
2197
14662198/// Indicates a particular Security ID may not be assigned as the label of an object.
14672199pub const INVALID_LABEL = 1299;
2200
14682201/// Not all privileges or groups referenced are assigned to the caller.
14692202pub const NOT_ALL_ASSIGNED = 1300;
2203
14702204/// Some mapping between account names and security IDs was not done.
14712205pub const SOME_NOT_MAPPED = 1301;
2206
14722207/// No system quota limits are specifically set for this account.
14732208pub const NO_QUOTAS_FOR_ACCOUNT = 1302;
2209
14742210/// No encryption key is available. A well-known encryption key was returned.
14752211pub const LOCAL_USER_SESSION_KEY = 1303;
2212
14762213/// The password is too complex to be converted to a LAN Manager password. The LAN Manager password returned is a NULL string.
14772214pub const NULL_LM_PASSWORD = 1304;
2215
14782216/// The revision level is unknown.
14792217pub const UNKNOWN_REVISION = 1305;
2218
14802219/// Indicates two revision levels are incompatible.
14812220pub const REVISION_MISMATCH = 1306;
2221
14822222/// This security ID may not be assigned as the owner of this object.
14832223pub const INVALID_OWNER = 1307;
2224
14842225/// This security ID may not be assigned as the primary group of an object.
14852226pub const INVALID_PRIMARY_GROUP = 1308;
2227
14862228/// An attempt has been made to operate on an impersonation token by a thread that is not currently impersonating a client.
14872229pub const NO_IMPERSONATION_TOKEN = 1309;
2230
14882231/// The group may not be disabled.
14892232pub const CANT_DISABLE_MANDATORY = 1310;
2233
14902234/// There are currently no logon servers available to service the logon request.
14912235pub const NO_LOGON_SERVERS = 1311;
2236
14922237/// A specified logon session does not exist. It may already have been terminated.
14932238pub const NO_SUCH_LOGON_SESSION = 1312;
2239
14942240/// A specified privilege does not exist.
14952241pub const NO_SUCH_PRIVILEGE = 1313;
2242
14962243/// A required privilege is not held by the client.
14972244pub const PRIVILEGE_NOT_HELD = 1314;
2245
14982246/// The name provided is not a properly formed account name.
14992247pub const INVALID_ACCOUNT_NAME = 1315;
2248
15002249/// The specified account already exists.
15012250pub const USER_EXISTS = 1316;
2251
15022252/// The specified account does not exist.
15032253pub const NO_SUCH_USER = 1317;
2254
15042255/// The specified group already exists.
15052256pub const GROUP_EXISTS = 1318;
2257
15062258/// The specified group does not exist.
15072259pub const NO_SUCH_GROUP = 1319;
2260
15082261/// Either the specified user account is already a member of the specified group, or the specified group cannot be deleted because it contains a member.
15092262pub const MEMBER_IN_GROUP = 1320;
2263
15102264/// The specified user account is not a member of the specified group account.
15112265pub const MEMBER_NOT_IN_GROUP = 1321;
2266
15122267/// This operation is disallowed as it could result in an administration account being disabled, deleted or unable to log on.
15132268pub const LAST_ADMIN = 1322;
2269
15142270/// Unable to update the password. The value provided as the current password is incorrect.
15152271pub const WRONG_PASSWORD = 1323;
2272
15162273/// Unable to update the password. The value provided for the new password contains values that are not allowed in passwords.
15172274pub const ILL_FORMED_PASSWORD = 1324;
2275
15182276/// Unable to update the password. The value provided for the new password does not meet the length, complexity, or history requirements of the domain.
15192277pub const PASSWORD_RESTRICTION = 1325;
2278
15202279/// The user name or password is incorrect.
15212280pub const LOGON_FAILURE = 1326;
2281
15222282/// Account restrictions are preventing this user from signing in. For example: blank passwords aren't allowed, sign-in times are limited, or a policy restriction has been enforced.
15232283pub const ACCOUNT_RESTRICTION = 1327;
2284
15242285/// Your account has time restrictions that keep you from signing in right now.
15252286pub const INVALID_LOGON_HOURS = 1328;
2287
15262288/// This user isn't allowed to sign in to this computer.
15272289pub const INVALID_WORKSTATION = 1329;
2290
15282291/// The password for this account has expired.
15292292pub const PASSWORD_EXPIRED = 1330;
2293
15302294/// This user can't sign in because this account is currently disabled.
15312295pub const ACCOUNT_DISABLED = 1331;
2296
15322297/// No mapping between account names and security IDs was done.
15332298pub const NONE_MAPPED = 1332;
2299
15342300/// Too many local user identifiers (LUIDs) were requested at one time.
15352301pub const TOO_MANY_LUIDS_REQUESTED = 1333;
2302
15362303/// No more local user identifiers (LUIDs) are available.
15372304pub const LUIDS_EXHAUSTED = 1334;
2305
15382306/// The subauthority part of a security ID is invalid for this particular use.
15392307pub const INVALID_SUB_AUTHORITY = 1335;
2308
15402309/// The access control list (ACL) structure is invalid.
15412310pub const INVALID_ACL = 1336;
2311
15422312/// The security ID structure is invalid.
15432313pub const INVALID_SID = 1337;
2314
15442315/// The security descriptor structure is invalid.
15452316pub const INVALID_SECURITY_DESCR = 1338;
2317
15462318/// The inherited access control list (ACL) or access control entry (ACE) could not be built.
15472319pub const BAD_INHERITANCE_ACL = 1340;
2320
15482321/// The server is currently disabled.
15492322pub const SERVER_DISABLED = 1341;
2323
15502324/// The server is currently enabled.
15512325pub const SERVER_NOT_DISABLED = 1342;
2326
15522327/// The value provided was an invalid value for an identifier authority.
15532328pub const INVALID_ID_AUTHORITY = 1343;
2329
15542330/// No more memory is available for security information updates.
15552331pub const ALLOTTED_SPACE_EXCEEDED = 1344;
2332
15562333/// The specified attributes are invalid, or incompatible with the attributes for the group as a whole.
15572334pub const INVALID_GROUP_ATTRIBUTES = 1345;
2335
15582336/// Either a required impersonation level was not provided, or the provided impersonation level is invalid.
15592337pub const BAD_IMPERSONATION_LEVEL = 1346;
2338
15602339/// Cannot open an anonymous level security token.
15612340pub const CANT_OPEN_ANONYMOUS = 1347;
2341
15622342/// The validation information class requested was invalid.
15632343pub const BAD_VALIDATION_CLASS = 1348;
2344
15642345/// The type of the token is inappropriate for its attempted use.
15652346pub const BAD_TOKEN_TYPE = 1349;
2347
15662348/// Unable to perform a security operation on an object that has no associated security.
15672349pub const NO_SECURITY_ON_OBJECT = 1350;
2350
15682351/// Configuration information could not be read from the domain controller, either because the machine is unavailable, or access has been denied.
15692352pub const CANT_ACCESS_DOMAIN_INFO = 1351;
2353
15702354/// The security account manager (SAM) or local security authority (LSA) server was in the wrong state to perform the security operation.
15712355pub const INVALID_SERVER_STATE = 1352;
2356
15722357/// The domain was in the wrong state to perform the security operation.
15732358pub const INVALID_DOMAIN_STATE = 1353;
2359
15742360/// This operation is only allowed for the Primary Domain Controller of the domain.
15752361pub const INVALID_DOMAIN_ROLE = 1354;
2362
15762363/// The specified domain either does not exist or could not be contacted.
15772364pub const NO_SUCH_DOMAIN = 1355;
2365
15782366/// The specified domain already exists.
15792367pub const DOMAIN_EXISTS = 1356;
2368
15802369/// An attempt was made to exceed the limit on the number of domains per server.
15812370pub const DOMAIN_LIMIT_EXCEEDED = 1357;
2371
15822372/// Unable to complete the requested operation because of either a catastrophic media failure or a data structure corruption on the disk.
15832373pub const INTERNAL_DB_CORRUPTION = 1358;
2374
15842375/// An internal error occurred.
15852376pub const INTERNAL_ERROR = 1359;
2377
15862378/// Generic access types were contained in an access mask which should already be mapped to nongeneric types.
15872379pub const GENERIC_NOT_MAPPED = 1360;
2380
15882381/// A security descriptor is not in the right format (absolute or self-relative).
15892382pub const BAD_DESCRIPTOR_FORMAT = 1361;
2383
15902384/// The requested action is restricted for use by logon processes only. The calling process has not registered as a logon process.
15912385pub const NOT_LOGON_PROCESS = 1362;
2386
15922387/// Cannot start a new logon session with an ID that is already in use.
15932388pub const LOGON_SESSION_EXISTS = 1363;
2389
15942390/// A specified authentication package is unknown.
15952391pub const NO_SUCH_PACKAGE = 1364;
2392
15962393/// The logon session is not in a state that is consistent with the requested operation.
15972394pub const BAD_LOGON_SESSION_STATE = 1365;
2395
15982396/// The logon session ID is already in use.
15992397pub const LOGON_SESSION_COLLISION = 1366;
2398
16002399/// A logon request contained an invalid logon type value.
16012400pub const INVALID_LOGON_TYPE = 1367;
2401
16022402/// Unable to impersonate using a named pipe until data has been read from that pipe.
16032403pub const CANNOT_IMPERSONATE = 1368;
2404
16042405/// The transaction state of a registry subtree is incompatible with the requested operation.
16052406pub const RXACT_INVALID_STATE = 1369;
2407
16062408/// An internal security database corruption has been encountered.
16072409pub const RXACT_COMMIT_FAILURE = 1370;
2410
16082411/// Cannot perform this operation on built-in accounts.
16092412pub const SPECIAL_ACCOUNT = 1371;
2413
16102414/// Cannot perform this operation on this built-in special group.
16112415pub const SPECIAL_GROUP = 1372;
2416
16122417/// Cannot perform this operation on this built-in special user.
16132418pub const SPECIAL_USER = 1373;
2419
16142420/// The user cannot be removed from a group because the group is currently the user's primary group.
16152421pub const MEMBERS_PRIMARY_GROUP = 1374;
2422
16162423/// The token is already in use as a primary token.
16172424pub const TOKEN_ALREADY_IN_USE = 1375;
2425
16182426/// The specified local group does not exist.
16192427pub const NO_SUCH_ALIAS = 1376;
2428
16202429/// The specified account name is not a member of the group.
16212430pub const MEMBER_NOT_IN_ALIAS = 1377;
2431
16222432/// The specified account name is already a member of the group.
16232433pub const MEMBER_IN_ALIAS = 1378;
2434
16242435/// The specified local group already exists.
16252436pub const ALIAS_EXISTS = 1379;
2437
16262438/// Logon failure: the user has not been granted the requested logon type at this computer.
16272439pub const LOGON_NOT_GRANTED = 1380;
2440
16282441/// The maximum number of secrets that may be stored in a single system has been exceeded.
16292442pub const TOO_MANY_SECRETS = 1381;
2443
16302444/// The length of a secret exceeds the maximum length allowed.
16312445pub const SECRET_TOO_LONG = 1382;
2446
16322447/// The local security authority database contains an internal inconsistency.
16332448pub const INTERNAL_DB_ERROR = 1383;
2449
16342450/// During a logon attempt, the user's security context accumulated too many security IDs.
16352451pub const TOO_MANY_CONTEXT_IDS = 1384;
2452
16362453/// Logon failure: the user has not been granted the requested logon type at this computer.
16372454pub const LOGON_TYPE_NOT_GRANTED = 1385;
2455
16382456/// A cross-encrypted password is necessary to change a user password.
16392457pub const NT_CROSS_ENCRYPTION_REQUIRED = 1386;
2458
16402459/// A member could not be added to or removed from the local group because the member does not exist.
16412460pub const NO_SUCH_MEMBER = 1387;
2461
16422462/// A new member could not be added to a local group because the member has the wrong account type.
16432463pub const INVALID_MEMBER = 1388;
2464
16442465/// Too many security IDs have been specified.
16452466pub const TOO_MANY_SIDS = 1389;
2467
16462468/// A cross-encrypted password is necessary to change this user password.
16472469pub const LM_CROSS_ENCRYPTION_REQUIRED = 1390;
2470
16482471/// Indicates an ACL contains no inheritable components.
16492472pub const NO_INHERITANCE = 1391;
2473
16502474/// The file or directory is corrupted and unreadable.
16512475pub const FILE_CORRUPT = 1392;
2476
16522477/// The disk structure is corrupted and unreadable.
16532478pub const DISK_CORRUPT = 1393;
2479
16542480/// There is no user session key for the specified logon session.
16552481pub const NO_USER_SESSION_KEY = 1394;
2482
16562483/// The service being accessed is licensed for a particular number of connections. No more connections can be made to the service at this time because there are already as many connections as the service can accept.
16572484pub const LICENSE_QUOTA_EXCEEDED = 1395;
2485
16582486/// The target account name is incorrect.
16592487pub const WRONG_TARGET_NAME = 1396;
2488
16602489/// Mutual Authentication failed. The server's password is out of date at the domain controller.
16612490pub const MUTUAL_AUTH_FAILED = 1397;
2491
16622492/// There is a time and/or date difference between the client and server.
16632493pub const TIME_SKEW = 1398;
2494
16642495/// This operation cannot be performed on the current domain.
16652496pub const CURRENT_DOMAIN_NOT_ALLOWED = 1399;
2497
16662498/// Invalid window handle.
16672499pub const INVALID_WINDOW_HANDLE = 1400;
2500
16682501/// Invalid menu handle.
16692502pub const INVALID_MENU_HANDLE = 1401;
2503
16702504/// Invalid cursor handle.
16712505pub const INVALID_CURSOR_HANDLE = 1402;
2506
16722507/// Invalid accelerator table handle.
16732508pub const INVALID_ACCEL_HANDLE = 1403;
2509
16742510/// Invalid hook handle.
16752511pub const INVALID_HOOK_HANDLE = 1404;
2512
16762513/// Invalid handle to a multiple-window position structure.
16772514pub const INVALID_DWP_HANDLE = 1405;
2515
16782516/// Cannot create a top-level child window.
16792517pub const TLW_WITH_WSCHILD = 1406;
2518
16802519/// Cannot find window class.
16812520pub const CANNOT_FIND_WND_CLASS = 1407;
2521
16822522/// Invalid window; it belongs to other thread.
16832523pub const WINDOW_OF_OTHER_THREAD = 1408;
2524
16842525/// Hot key is already registered.
16852526pub const HOTKEY_ALREADY_REGISTERED = 1409;
2527
16862528/// Class already exists.
16872529pub const CLASS_ALREADY_EXISTS = 1410;
2530
16882531/// Class does not exist.
16892532pub const CLASS_DOES_NOT_EXIST = 1411;
2533
16902534/// Class still has open windows.
16912535pub const CLASS_HAS_WINDOWS = 1412;
2536
16922537/// Invalid index.
16932538pub const INVALID_INDEX = 1413;
2539
16942540/// Invalid icon handle.
16952541pub const INVALID_ICON_HANDLE = 1414;
2542
16962543/// Using private DIALOG window words.
16972544pub const PRIVATE_DIALOG_INDEX = 1415;
2545
16982546/// The list box identifier was not found.
16992547pub const LISTBOX_ID_NOT_FOUND = 1416;
2548
17002549/// No wildcards were found.
17012550pub const NO_WILDCARD_CHARACTERS = 1417;
2551
17022552/// Thread does not have a clipboard open.
17032553pub const CLIPBOARD_NOT_OPEN = 1418;
2554
17042555/// Hot key is not registered.
17052556pub const HOTKEY_NOT_REGISTERED = 1419;
2557
17062558/// The window is not a valid dialog window.
17072559pub const WINDOW_NOT_DIALOG = 1420;
2560
17082561/// Control ID not found.
17092562pub const CONTROL_ID_NOT_FOUND = 1421;
2563
17102564/// Invalid message for a combo box because it does not have an edit control.
17112565pub const INVALID_COMBOBOX_MESSAGE = 1422;
2566
17122567/// The window is not a combo box.
17132568pub const WINDOW_NOT_COMBOBOX = 1423;
2569
17142570/// Height must be less than 256.
17152571pub const INVALID_EDIT_HEIGHT = 1424;
2572
17162573/// Invalid device context (DC) handle.
17172574pub const DC_NOT_FOUND = 1425;
2575
17182576/// Invalid hook procedure type.
17192577pub const INVALID_HOOK_FILTER = 1426;
2578
17202579/// Invalid hook procedure.
17212580pub const INVALID_FILTER_PROC = 1427;
2581
17222582/// Cannot set nonlocal hook without a module handle.
17232583pub const HOOK_NEEDS_HMOD = 1428;
2584
17242585/// This hook procedure can only be set globally.
17252586pub const GLOBAL_ONLY_HOOK = 1429;
2587
17262588/// The journal hook procedure is already installed.
17272589pub const JOURNAL_HOOK_SET = 1430;
2590
17282591/// The hook procedure is not installed.
17292592pub const HOOK_NOT_INSTALLED = 1431;
2593
17302594/// Invalid message for single-selection list box.
17312595pub const INVALID_LB_MESSAGE = 1432;
2596
17322597/// LB_SETCOUNT sent to non-lazy list box.
17332598pub const SETCOUNT_ON_BAD_LB = 1433;
2599
17342600/// This list box does not support tab stops.
17352601pub const LB_WITHOUT_TABSTOPS = 1434;
2602
17362603/// Cannot destroy object created by another thread.
17372604pub const DESTROY_OBJECT_OF_OTHER_THREAD = 1435;
2605
17382606/// Child windows cannot have menus.
17392607pub const CHILD_WINDOW_MENU = 1436;
2608
17402609/// The window does not have a system menu.
17412610pub const NO_SYSTEM_MENU = 1437;
2611
17422612/// Invalid message box style.
17432613pub const INVALID_MSGBOX_STYLE = 1438;
2614
17442615/// Invalid system-wide (SPI_*) parameter.
17452616pub const INVALID_SPI_VALUE = 1439;
2617
17462618/// Screen already locked.
17472619pub const SCREEN_ALREADY_LOCKED = 1440;
2620
17482621/// All handles to windows in a multiple-window position structure must have the same parent.
17492622pub const HWNDS_HAVE_DIFF_PARENT = 1441;
2623
17502624/// The window is not a child window.
17512625pub const NOT_CHILD_WINDOW = 1442;
2626
17522627/// Invalid GW_* command.
17532628pub const INVALID_GW_COMMAND = 1443;
2629
17542630/// Invalid thread identifier.
17552631pub const INVALID_THREAD_ID = 1444;
2632
17562633/// Cannot process a message from a window that is not a multiple document interface (MDI) window.
17572634pub const NON_MDICHILD_WINDOW = 1445;
2635
17582636/// Popup menu already active.
17592637pub const POPUP_ALREADY_ACTIVE = 1446;
2638
17602639/// The window does not have scroll bars.
17612640pub const NO_SCROLLBARS = 1447;
2641
17622642/// Scroll bar range cannot be greater than MAXLONG.
17632643pub const INVALID_SCROLLBAR_RANGE = 1448;
2644
17642645/// Cannot show or remove the window in the way specified.
17652646pub const INVALID_SHOWWIN_COMMAND = 1449;
2647
17662648/// Insufficient system resources exist to complete the requested service.
17672649pub const NO_SYSTEM_RESOURCES = 1450;
2650
17682651/// Insufficient system resources exist to complete the requested service.
17692652pub const NONPAGED_SYSTEM_RESOURCES = 1451;
2653
17702654/// Insufficient system resources exist to complete the requested service.
17712655pub const PAGED_SYSTEM_RESOURCES = 1452;
2656
17722657/// Insufficient quota to complete the requested service.
17732658pub const WORKING_SET_QUOTA = 1453;
2659
17742660/// Insufficient quota to complete the requested service.
17752661pub const PAGEFILE_QUOTA = 1454;
2662
17762663/// The paging file is too small for this operation to complete.
17772664pub const COMMITMENT_LIMIT = 1455;
2665
17782666/// A menu item was not found.
17792667pub const MENU_ITEM_NOT_FOUND = 1456;
2668
17802669/// Invalid keyboard layout handle.
17812670pub const INVALID_KEYBOARD_HANDLE = 1457;
2671
17822672/// Hook type not allowed.
17832673pub const HOOK_TYPE_NOT_ALLOWED = 1458;
2674
17842675/// This operation requires an interactive window station.
17852676pub const REQUIRES_INTERACTIVE_WINDOWSTATION = 1459;
2677
17862678/// This operation returned because the timeout period expired.
17872679pub const TIMEOUT = 1460;
2680
17882681/// Invalid monitor handle.
17892682pub const INVALID_MONITOR_HANDLE = 1461;
2683
17902684/// Incorrect size argument.
17912685pub const INCORRECT_SIZE = 1462;
2686
17922687/// The symbolic link cannot be followed because its type is disabled.
17932688pub const SYMLINK_CLASS_DISABLED = 1463;
2689
17942690/// This application does not support the current operation on symbolic links.
17952691pub const SYMLINK_NOT_SUPPORTED = 1464;
2692
17962693/// Windows was unable to parse the requested XML data.
17972694pub const XML_PARSE_ERROR = 1465;
2695
17982696/// An error was encountered while processing an XML digital signature.
17992697pub const XMLDSIG_ERROR = 1466;
2698
18002699/// This application must be restarted.
18012700pub const RESTART_APPLICATION = 1467;
2701
18022702/// The caller made the connection request in the wrong routing compartment.
18032703pub const WRONG_COMPARTMENT = 1468;
2704
18042705/// There was an AuthIP failure when attempting to connect to the remote host.
18052706pub const AUTHIP_FAILURE = 1469;
2707
18062708/// Insufficient NVRAM resources exist to complete the requested service. A reboot might be required.
18072709pub const NO_NVRAM_RESOURCES = 1470;
2710
18082711/// Unable to finish the requested operation because the specified process is not a GUI process.
18092712pub const NOT_GUI_PROCESS = 1471;
2713
18102714/// The event log file is corrupted.
18112715pub const EVENTLOG_FILE_CORRUPT = 1500;
2716
18122717/// No event log file could be opened, so the event logging service did not start.
18132718pub const EVENTLOG_CANT_START = 1501;
2719
18142720/// The event log file is full.
18152721pub const LOG_FILE_FULL = 1502;
2722
18162723/// The event log file has changed between read operations.
18172724pub const EVENTLOG_FILE_CHANGED = 1503;
2725
18182726/// The specified task name is invalid.
18192727pub const INVALID_TASK_NAME = 1550;
2728
18202729/// The specified task index is invalid.
18212730pub const INVALID_TASK_INDEX = 1551;
2731
18222732/// The specified thread is already joining a task.
18232733pub const THREAD_ALREADY_IN_TASK = 1552;
2734
18242735/// The Windows Installer Service could not be accessed. This can occur if the Windows Installer is not correctly installed. Contact your support personnel for assistance.
18252736pub const INSTALL_SERVICE_FAILURE = 1601;
2737
18262738/// User cancelled installation.
18272739pub const INSTALL_USEREXIT = 1602;
2740
18282741/// Fatal error during installation.
18292742pub const INSTALL_FAILURE = 1603;
2743
18302744/// Installation suspended, incomplete.
18312745pub const INSTALL_SUSPEND = 1604;
2746
18322747/// This action is only valid for products that are currently installed.
18332748pub const UNKNOWN_PRODUCT = 1605;
2749
18342750/// Feature ID not registered.
18352751pub const UNKNOWN_FEATURE = 1606;
2752
18362753/// Component ID not registered.
18372754pub const UNKNOWN_COMPONENT = 1607;
2755
18382756/// Unknown property.
18392757pub const UNKNOWN_PROPERTY = 1608;
2758
18402759/// Handle is in an invalid state.
18412760pub const INVALID_HANDLE_STATE = 1609;
2761
18422762/// The configuration data for this product is corrupt. Contact your support personnel.
18432763pub const BAD_CONFIGURATION = 1610;
2764
18442765/// Component qualifier not present.
18452766pub const INDEX_ABSENT = 1611;
2767
18462768/// The installation source for this product is not available. Verify that the source exists and that you can access it.
18472769pub const INSTALL_SOURCE_ABSENT = 1612;
2770
18482771/// This installation package cannot be installed by the Windows Installer service. You must install a Windows service pack that contains a newer version of the Windows Installer service.
18492772pub const INSTALL_PACKAGE_VERSION = 1613;
2773
18502774/// Product is uninstalled.
18512775pub const PRODUCT_UNINSTALLED = 1614;
2776
18522777/// SQL query syntax invalid or unsupported.
18532778pub const BAD_QUERY_SYNTAX = 1615;
2779
18542780/// Record field does not exist.
18552781pub const INVALID_FIELD = 1616;
2782
18562783/// The device has been removed.
18572784pub const DEVICE_REMOVED = 1617;
2785
18582786/// Another installation is already in progress. Complete that installation before proceeding with this install.
18592787pub const INSTALL_ALREADY_RUNNING = 1618;
2788
18602789/// This installation package could not be opened. Verify that the package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer package.
18612790pub const INSTALL_PACKAGE_OPEN_FAILED = 1619;
2791
18622792/// This installation package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer package.
18632793pub const INSTALL_PACKAGE_INVALID = 1620;
2794
18642795/// There was an error starting the Windows Installer service user interface. Contact your support personnel.
18652796pub const INSTALL_UI_FAILURE = 1621;
2797
18662798/// Error opening installation log file. Verify that the specified log file location exists and that you can write to it.
18672799pub const INSTALL_LOG_FAILURE = 1622;
2800
18682801/// The language of this installation package is not supported by your system.
18692802pub const INSTALL_LANGUAGE_UNSUPPORTED = 1623;
2803
18702804/// Error applying transforms. Verify that the specified transform paths are valid.
18712805pub const INSTALL_TRANSFORM_FAILURE = 1624;
2806
18722807/// This installation is forbidden by system policy. Contact your system administrator.
18732808pub const INSTALL_PACKAGE_REJECTED = 1625;
2809
18742810/// Function could not be executed.
18752811pub const FUNCTION_NOT_CALLED = 1626;
2812
18762813/// Function failed during execution.
18772814pub const FUNCTION_FAILED = 1627;
2815
18782816/// Invalid or unknown table specified.
18792817pub const INVALID_TABLE = 1628;
2818
18802819/// Data supplied is of wrong type.
18812820pub const DATATYPE_MISMATCH = 1629;
2821
18822822/// Data of this type is not supported.
18832823pub const UNSUPPORTED_TYPE = 1630;
2824
18842825/// The Windows Installer service failed to start. Contact your support personnel.
18852826pub const CREATE_FAILED = 1631;
2827
18862828/// The Temp folder is on a drive that is full or is inaccessible. Free up space on the drive or verify that you have write permission on the Temp folder.
18872829pub const INSTALL_TEMP_UNWRITABLE = 1632;
2830
18882831/// This installation package is not supported by this processor type. Contact your product vendor.
18892832pub const INSTALL_PLATFORM_UNSUPPORTED = 1633;
2833
18902834/// Component not used on this computer.
18912835pub const INSTALL_NOTUSED = 1634;
2836
18922837/// This update package could not be opened. Verify that the update package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer update package.
18932838pub const PATCH_PACKAGE_OPEN_FAILED = 1635;
2839
18942840/// This update package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer update package.
18952841pub const PATCH_PACKAGE_INVALID = 1636;
2842
18962843/// This update package cannot be processed by the Windows Installer service. You must install a Windows service pack that contains a newer version of the Windows Installer service.
18972844pub const PATCH_PACKAGE_UNSUPPORTED = 1637;
2845
18982846/// Another version of this product is already installed. Installation of this version cannot continue. To configure or remove the existing version of this product, use Add/Remove Programs on the Control Panel.
18992847pub const PRODUCT_VERSION = 1638;
2848
19002849/// Invalid command line argument. Consult the Windows Installer SDK for detailed command line help.
19012850pub const INVALID_COMMAND_LINE = 1639;
2851
19022852/// Only administrators have permission to add, remove, or configure server software during a Terminal services remote session. If you want to install or configure software on the server, contact your network administrator.
19032853pub const INSTALL_REMOTE_DISALLOWED = 1640;
2854
19042855/// The requested operation completed successfully. The system will be restarted so the changes can take effect.
19052856pub const SUCCESS_REBOOT_INITIATED = 1641;
2857
19062858/// The upgrade cannot be installed by the Windows Installer service because the program to be upgraded may be missing, or the upgrade may update a different version of the program. Verify that the program to be upgraded exists on your computer and that you have the correct upgrade.
19072859pub const PATCH_TARGET_NOT_FOUND = 1642;
2860
19082861/// The update package is not permitted by software restriction policy.
19092862pub const PATCH_PACKAGE_REJECTED = 1643;
2863
19102864/// One or more customizations are not permitted by software restriction policy.
19112865pub const INSTALL_TRANSFORM_REJECTED = 1644;
2866
19122867/// The Windows Installer does not permit installation from a Remote Desktop Connection.
19132868pub const INSTALL_REMOTE_PROHIBITED = 1645;
2869
19142870/// Uninstallation of the update package is not supported.
19152871pub const PATCH_REMOVAL_UNSUPPORTED = 1646;
2872
19162873/// The update is not applied to this product.
19172874pub const UNKNOWN_PATCH = 1647;
2875
19182876/// No valid sequence could be found for the set of updates.
19192877pub const PATCH_NO_SEQUENCE = 1648;
2878
19202879/// Update removal was disallowed by policy.
19212880pub const PATCH_REMOVAL_DISALLOWED = 1649;
2881
19222882/// The XML update data is invalid.
19232883pub const INVALID_PATCH_XML = 1650;
2884
19242885/// Windows Installer does not permit updating of managed advertised products. At least one feature of the product must be installed before applying the update.
19252886pub const PATCH_MANAGED_ADVERTISED_PRODUCT = 1651;
2887
19262888/// The Windows Installer service is not accessible in Safe Mode. Please try again when your computer is not in Safe Mode or you can use System Restore to return your machine to a previous good state.
19272889pub const INSTALL_SERVICE_SAFEBOOT = 1652;
2890
19282891/// A fail fast exception occurred. Exception handlers will not be invoked and the process will be terminated immediately.
19292892pub const FAIL_FAST_EXCEPTION = 1653;
2893
19302894/// The app that you are trying to run is not supported on this version of Windows.
19312895pub const INSTALL_REJECTED = 1654;
2896
19322897/// The string binding is invalid.
19332898pub const RPC_S_INVALID_STRING_BINDING = 1700;
2899
19342900/// The binding handle is not the correct type.
19352901pub const RPC_S_WRONG_KIND_OF_BINDING = 1701;
2902
19362903/// The binding handle is invalid.
19372904pub const RPC_S_INVALID_BINDING = 1702;
2905
19382906/// The RPC protocol sequence is not supported.
19392907pub const RPC_S_PROTSEQ_NOT_SUPPORTED = 1703;
2908
19402909/// The RPC protocol sequence is invalid.
19412910pub const RPC_S_INVALID_RPC_PROTSEQ = 1704;
2911
19422912/// The string universal unique identifier (UUID) is invalid.
19432913pub const RPC_S_INVALID_STRING_UUID = 1705;
2914
19442915/// The endpoint format is invalid.
19452916pub const RPC_S_INVALID_ENDPOINT_FORMAT = 1706;
2917
19462918/// The network address is invalid.
19472919pub const RPC_S_INVALID_NET_ADDR = 1707;
2920
19482921/// No endpoint was found.
19492922pub const RPC_S_NO_ENDPOINT_FOUND = 1708;
2923
19502924/// The timeout value is invalid.
19512925pub const RPC_S_INVALID_TIMEOUT = 1709;
2926
19522927/// The object universal unique identifier (UUID) was not found.
19532928pub const RPC_S_OBJECT_NOT_FOUND = 1710;
2929
19542930/// The object universal unique identifier (UUID) has already been registered.
19552931pub const RPC_S_ALREADY_REGISTERED = 1711;
2932
19562933/// The type universal unique identifier (UUID) has already been registered.
19572934pub const RPC_S_TYPE_ALREADY_REGISTERED = 1712;
2935
19582936/// The RPC server is already listening.
19592937pub const RPC_S_ALREADY_LISTENING = 1713;
2938
19602939/// No protocol sequences have been registered.
19612940pub const RPC_S_NO_PROTSEQS_REGISTERED = 1714;
2941
19622942/// The RPC server is not listening.
19632943pub const RPC_S_NOT_LISTENING = 1715;
2944
19642945/// The manager type is unknown.
19652946pub const RPC_S_UNKNOWN_MGR_TYPE = 1716;
2947
19662948/// The interface is unknown.
19672949pub const RPC_S_UNKNOWN_IF = 1717;
2950
19682951/// There are no bindings.
19692952pub const RPC_S_NO_BINDINGS = 1718;
2953
19702954/// There are no protocol sequences.
19712955pub const RPC_S_NO_PROTSEQS = 1719;
2956
19722957/// The endpoint cannot be created.
19732958pub const RPC_S_CANT_CREATE_ENDPOINT = 1720;
2959
19742960/// Not enough resources are available to complete this operation.
19752961pub const RPC_S_OUT_OF_RESOURCES = 1721;
2962
19762963/// The RPC server is unavailable.
19772964pub const RPC_S_SERVER_UNAVAILABLE = 1722;
2965
19782966/// The RPC server is too busy to complete this operation.
19792967pub const RPC_S_SERVER_TOO_BUSY = 1723;
2968
19802969/// The network options are invalid.
19812970pub const RPC_S_INVALID_NETWORK_OPTIONS = 1724;
2971
19822972/// There are no remote procedure calls active on this thread.
19832973pub const RPC_S_NO_CALL_ACTIVE = 1725;
2974
19842975/// The remote procedure call failed.
19852976pub const RPC_S_CALL_FAILED = 1726;
2977
19862978/// The remote procedure call failed and did not execute.
19872979pub const RPC_S_CALL_FAILED_DNE = 1727;
2980
19882981/// A remote procedure call (RPC) protocol error occurred.
19892982pub const RPC_S_PROTOCOL_ERROR = 1728;
2983
19902984/// Access to the HTTP proxy is denied.
19912985pub const RPC_S_PROXY_ACCESS_DENIED = 1729;
2986
19922987/// The transfer syntax is not supported by the RPC server.
19932988pub const RPC_S_UNSUPPORTED_TRANS_SYN = 1730;
2989
19942990/// The universal unique identifier (UUID) type is not supported.
19952991pub const RPC_S_UNSUPPORTED_TYPE = 1732;
2992
19962993/// The tag is invalid.
19972994pub const RPC_S_INVALID_TAG = 1733;
2995
19982996/// The array bounds are invalid.
19992997pub const RPC_S_INVALID_BOUND = 1734;
2998
20002999/// The binding does not contain an entry name.
20013000pub const RPC_S_NO_ENTRY_NAME = 1735;
3001
20023002/// The name syntax is invalid.
20033003pub const RPC_S_INVALID_NAME_SYNTAX = 1736;
3004
20043005/// The name syntax is not supported.
20053006pub const RPC_S_UNSUPPORTED_NAME_SYNTAX = 1737;
3007
20063008/// No network address is available to use to construct a universal unique identifier (UUID).
20073009pub const RPC_S_UUID_NO_ADDRESS = 1739;
3010
20083011/// The endpoint is a duplicate.
20093012pub const RPC_S_DUPLICATE_ENDPOINT = 1740;
3013
20103014/// The authentication type is unknown.
20113015pub const RPC_S_UNKNOWN_AUTHN_TYPE = 1741;
3016
20123017/// The maximum number of calls is too small.
20133018pub const RPC_S_MAX_CALLS_TOO_SMALL = 1742;
3019
20143020/// The string is too long.
20153021pub const RPC_S_STRING_TOO_LONG = 1743;
3022
20163023/// The RPC protocol sequence was not found.
20173024pub const RPC_S_PROTSEQ_NOT_FOUND = 1744;
3025
20183026/// The procedure number is out of range.
20193027pub const RPC_S_PROCNUM_OUT_OF_RANGE = 1745;
3028
20203029/// The binding does not contain any authentication information.
20213030pub const RPC_S_BINDING_HAS_NO_AUTH = 1746;
3031
20223032/// The authentication service is unknown.
20233033pub const RPC_S_UNKNOWN_AUTHN_SERVICE = 1747;
3034
20243035/// The authentication level is unknown.
20253036pub const RPC_S_UNKNOWN_AUTHN_LEVEL = 1748;
3037
20263038/// The security context is invalid.
20273039pub const RPC_S_INVALID_AUTH_IDENTITY = 1749;
3040
20283041/// The authorization service is unknown.
20293042pub const RPC_S_UNKNOWN_AUTHZ_SERVICE = 1750;
3043
20303044/// The entry is invalid.
20313045pub const EPT_S_INVALID_ENTRY = 1751;
3046
20323047/// The server endpoint cannot perform the operation.
20333048pub const EPT_S_CANT_PERFORM_OP = 1752;
3049
20343050/// There are no more endpoints available from the endpoint mapper.
20353051pub const EPT_S_NOT_REGISTERED = 1753;
3052
20363053/// No interfaces have been exported.
20373054pub const RPC_S_NOTHING_TO_EXPORT = 1754;
3055
20383056/// The entry name is incomplete.
20393057pub const RPC_S_INCOMPLETE_NAME = 1755;
3058
20403059/// The version option is invalid.
20413060pub const RPC_S_INVALID_VERS_OPTION = 1756;
3061
20423062/// There are no more members.
20433063pub const RPC_S_NO_MORE_MEMBERS = 1757;
3064
20443065/// There is nothing to unexport.
20453066pub const RPC_S_NOT_ALL_OBJS_UNEXPORTED = 1758;
3067
20463068/// The interface was not found.
20473069pub const RPC_S_INTERFACE_NOT_FOUND = 1759;
3070
20483071/// The entry already exists.
20493072pub const RPC_S_ENTRY_ALREADY_EXISTS = 1760;
3073
20503074/// The entry is not found.
20513075pub const RPC_S_ENTRY_NOT_FOUND = 1761;
3076
20523077/// The name service is unavailable.
20533078pub const RPC_S_NAME_SERVICE_UNAVAILABLE = 1762;
3079
20543080/// The network address family is invalid.
20553081pub const RPC_S_INVALID_NAF_ID = 1763;
3082
20563083/// The requested operation is not supported.
20573084pub const RPC_S_CANNOT_SUPPORT = 1764;
3085
20583086/// No security context is available to allow impersonation.
20593087pub const RPC_S_NO_CONTEXT_AVAILABLE = 1765;
3088
20603089/// An internal error occurred in a remote procedure call (RPC).
20613090pub const RPC_S_INTERNAL_ERROR = 1766;
3091
20623092/// The RPC server attempted an integer division by zero.
20633093pub const RPC_S_ZERO_DIVIDE = 1767;
3094
20643095/// An addressing error occurred in the RPC server.
20653096pub const RPC_S_ADDRESS_ERROR = 1768;
3097
20663098/// A floating-point operation at the RPC server caused a division by zero.
20673099pub const RPC_S_FP_DIV_ZERO = 1769;
3100
20683101/// A floating-point underflow occurred at the RPC server.
20693102pub const RPC_S_FP_UNDERFLOW = 1770;
3103
20703104/// A floating-point overflow occurred at the RPC server.
20713105pub const RPC_S_FP_OVERFLOW = 1771;
3106
20723107/// The list of RPC servers available for the binding of auto handles has been exhausted.
20733108pub const RPC_X_NO_MORE_ENTRIES = 1772;
3109
20743110/// Unable to open the character translation table file.
20753111pub const RPC_X_SS_CHAR_TRANS_OPEN_FAIL = 1773;
3112
20763113/// The file containing the character translation table has fewer than 512 bytes.
20773114pub const RPC_X_SS_CHAR_TRANS_SHORT_FILE = 1774;
3115
20783116/// A null context handle was passed from the client to the host during a remote procedure call.
20793117pub const RPC_X_SS_IN_NULL_CONTEXT = 1775;
3118
20803119/// The context handle changed during a remote procedure call.
20813120pub const RPC_X_SS_CONTEXT_DAMAGED = 1777;
3121
20823122/// The binding handles passed to a remote procedure call do not match.
20833123pub const RPC_X_SS_HANDLES_MISMATCH = 1778;
3124
20843125/// The stub is unable to get the remote procedure call handle.
20853126pub const RPC_X_SS_CANNOT_GET_CALL_HANDLE = 1779;
3127
20863128/// A null reference pointer was passed to the stub.
20873129pub const RPC_X_NULL_REF_POINTER = 1780;
3130
20883131/// The enumeration value is out of range.
20893132pub const RPC_X_ENUM_VALUE_OUT_OF_RANGE = 1781;
3133
20903134/// The byte count is too small.
20913135pub const RPC_X_BYTE_COUNT_TOO_SMALL = 1782;
3136
20923137/// The stub received bad data.
20933138pub const RPC_X_BAD_STUB_DATA = 1783;
3139
20943140/// The supplied user buffer is not valid for the requested operation.
20953141pub const INVALID_USER_BUFFER = 1784;
3142
20963143/// The disk media is not recognized. It may not be formatted.
20973144pub const UNRECOGNIZED_MEDIA = 1785;
3145
20983146/// The workstation does not have a trust secret.
20993147pub const NO_TRUST_LSA_SECRET = 1786;
3148
21003149/// The security database on the server does not have a computer account for this workstation trust relationship.
21013150pub const NO_TRUST_SAM_ACCOUNT = 1787;
3151
21023152/// The trust relationship between the primary domain and the trusted domain failed.
21033153pub const TRUSTED_DOMAIN_FAILURE = 1788;
3154
21043155/// The trust relationship between this workstation and the primary domain failed.
21053156pub const TRUSTED_RELATIONSHIP_FAILURE = 1789;
3157
21063158/// The network logon failed.
21073159pub const TRUST_FAILURE = 1790;
3160
21083161/// A remote procedure call is already in progress for this thread.
21093162pub const RPC_S_CALL_IN_PROGRESS = 1791;
3163
21103164/// An attempt was made to logon, but the network logon service was not started.
21113165pub const NETLOGON_NOT_STARTED = 1792;
3166
21123167/// The user's account has expired.
21133168pub const ACCOUNT_EXPIRED = 1793;
3169
21143170/// The redirector is in use and cannot be unloaded.
21153171pub const REDIRECTOR_HAS_OPEN_HANDLES = 1794;
3172
21163173/// The specified printer driver is already installed.
21173174pub const PRINTER_DRIVER_ALREADY_INSTALLED = 1795;
3175
21183176/// The specified port is unknown.
21193177pub const UNKNOWN_PORT = 1796;
3178
21203179/// The printer driver is unknown.
21213180pub const UNKNOWN_PRINTER_DRIVER = 1797;
3181
21223182/// The print processor is unknown.
21233183pub const UNKNOWN_PRINTPROCESSOR = 1798;
3184
21243185/// The specified separator file is invalid.
21253186pub const INVALID_SEPARATOR_FILE = 1799;
3187
21263188/// The specified priority is invalid.
21273189pub const INVALID_PRIORITY = 1800;
3190
21283191/// The printer name is invalid.
21293192pub const INVALID_PRINTER_NAME = 1801;
3193
21303194/// The printer already exists.
21313195pub const PRINTER_ALREADY_EXISTS = 1802;
3196
21323197/// The printer command is invalid.
21333198pub const INVALID_PRINTER_COMMAND = 1803;
3199
21343200/// The specified datatype is invalid.
21353201pub const INVALID_DATATYPE = 1804;
3202
21363203/// The environment specified is invalid.
21373204pub const INVALID_ENVIRONMENT = 1805;
3205
21383206/// There are no more bindings.
21393207pub const RPC_S_NO_MORE_BINDINGS = 1806;
3208
21403209/// The account used is an interdomain trust account. Use your global user account or local user account to access this server.
21413210pub const NOLOGON_INTERDOMAIN_TRUST_ACCOUNT = 1807;
3211
21423212/// The account used is a computer account. Use your global user account or local user account to access this server.
21433213pub const NOLOGON_WORKSTATION_TRUST_ACCOUNT = 1808;
3214
21443215/// The account used is a server trust account. Use your global user account or local user account to access this server.
21453216pub const NOLOGON_SERVER_TRUST_ACCOUNT = 1809;
3217
21463218/// The name or security ID (SID) of the domain specified is inconsistent with the trust information for that domain.
21473219pub const DOMAIN_TRUST_INCONSISTENT = 1810;
3220
21483221/// The server is in use and cannot be unloaded.
21493222pub const SERVER_HAS_OPEN_HANDLES = 1811;
3223
21503224/// The specified image file did not contain a resource section.
21513225pub const RESOURCE_DATA_NOT_FOUND = 1812;
3226
21523227/// The specified resource type cannot be found in the image file.
21533228pub const RESOURCE_TYPE_NOT_FOUND = 1813;
3229
21543230/// The specified resource name cannot be found in the image file.
21553231pub const RESOURCE_NAME_NOT_FOUND = 1814;
3232
21563233/// The specified resource language ID cannot be found in the image file.
21573234pub const RESOURCE_LANG_NOT_FOUND = 1815;
3235
21583236/// Not enough quota is available to process this command.
21593237pub const NOT_ENOUGH_QUOTA = 1816;
3238
21603239/// No interfaces have been registered.
21613240pub const RPC_S_NO_INTERFACES = 1817;
3241
21623242/// The remote procedure call was cancelled.
21633243pub const RPC_S_CALL_CANCELLED = 1818;
3244
21643245/// The binding handle does not contain all required information.
21653246pub const RPC_S_BINDING_INCOMPLETE = 1819;
3247
21663248/// A communications failure occurred during a remote procedure call.
21673249pub const RPC_S_COMM_FAILURE = 1820;
3250
21683251/// The requested authentication level is not supported.
21693252pub const RPC_S_UNSUPPORTED_AUTHN_LEVEL = 1821;
3253
21703254/// No principal name registered.
21713255pub const RPC_S_NO_PRINC_NAME = 1822;
3256
21723257/// The error specified is not a valid Windows RPC error code.
21733258pub const RPC_S_NOT_RPC_ERROR = 1823;
3259
21743260/// A UUID that is valid only on this computer has been allocated.
21753261pub const RPC_S_UUID_LOCAL_ONLY = 1824;
3262
21763263/// A security package specific error occurred.
21773264pub const RPC_S_SEC_PKG_ERROR = 1825;
3265
21783266/// Thread is not canceled.
21793267pub const RPC_S_NOT_CANCELLED = 1826;
3268
21803269/// Invalid operation on the encoding/decoding handle.
21813270pub const RPC_X_INVALID_ES_ACTION = 1827;
3271
21823272/// Incompatible version of the serializing package.
21833273pub const RPC_X_WRONG_ES_VERSION = 1828;
3274
21843275/// Incompatible version of the RPC stub.
21853276pub const RPC_X_WRONG_STUB_VERSION = 1829;
3277
21863278/// The RPC pipe object is invalid or corrupted.
21873279pub const RPC_X_INVALID_PIPE_OBJECT = 1830;
3280
21883281/// An invalid operation was attempted on an RPC pipe object.
21893282pub const RPC_X_WRONG_PIPE_ORDER = 1831;
3283
21903284/// Unsupported RPC pipe version.
21913285pub const RPC_X_WRONG_PIPE_VERSION = 1832;
3286
21923287/// HTTP proxy server rejected the connection because the cookie authentication failed.
21933288pub const RPC_S_COOKIE_AUTH_FAILED = 1833;
3289
21943290/// The group member was not found.
21953291pub const RPC_S_GROUP_MEMBER_NOT_FOUND = 1898;
3292
21963293/// The endpoint mapper database entry could not be created.
21973294pub const EPT_S_CANT_CREATE = 1899;
3295
21983296/// The object universal unique identifier (UUID) is the nil UUID.
21993297pub const RPC_S_INVALID_OBJECT = 1900;
3298
22003299/// The specified time is invalid.
22013300pub const INVALID_TIME = 1901;
3301
22023302/// The specified form name is invalid.
22033303pub const INVALID_FORM_NAME = 1902;
3304
22043305/// The specified form size is invalid.
22053306pub const INVALID_FORM_SIZE = 1903;
3307
22063308/// The specified printer handle is already being waited on.
22073309pub const ALREADY_WAITING = 1904;
3310
22083311/// The specified printer has been deleted.
22093312pub const PRINTER_DELETED = 1905;
3313
22103314/// The state of the printer is invalid.
22113315pub const INVALID_PRINTER_STATE = 1906;
3316
22123317/// The user's password must be changed before signing in.
22133318pub const PASSWORD_MUST_CHANGE = 1907;
3319
22143320/// Could not find the domain controller for this domain.
22153321pub const DOMAIN_CONTROLLER_NOT_FOUND = 1908;
3322
22163323/// The referenced account is currently locked out and may not be logged on to.
22173324pub const ACCOUNT_LOCKED_OUT = 1909;
3325
22183326/// The object exporter specified was not found.
22193327pub const OR_INVALID_OXID = 1910;
3328
22203329/// The object specified was not found.
22213330pub const OR_INVALID_OID = 1911;
3331
22223332/// The object resolver set specified was not found.
22233333pub const OR_INVALID_SET = 1912;
3334
22243335/// Some data remains to be sent in the request buffer.
22253336pub const RPC_S_SEND_INCOMPLETE = 1913;
3337
22263338/// Invalid asynchronous remote procedure call handle.
22273339pub const RPC_S_INVALID_ASYNC_HANDLE = 1914;
3340
22283341/// Invalid asynchronous RPC call handle for this operation.
22293342pub const RPC_S_INVALID_ASYNC_CALL = 1915;
3343
22303344/// The RPC pipe object has already been closed.
22313345pub const RPC_X_PIPE_CLOSED = 1916;
3346
22323347/// The RPC call completed before all pipes were processed.
22333348pub const RPC_X_PIPE_DISCIPLINE_ERROR = 1917;
3349
22343350/// No more data is available from the RPC pipe.
22353351pub const RPC_X_PIPE_EMPTY = 1918;
3352
22363353/// No site name is available for this machine.
22373354pub const NO_SITENAME = 1919;
3355
22383356/// The file cannot be accessed by the system.
22393357pub const CANT_ACCESS_FILE = 1920;
3358
22403359/// The name of the file cannot be resolved by the system.
22413360pub const CANT_RESOLVE_FILENAME = 1921;
3361
22423362/// The entry is not of the expected type.
22433363pub const RPC_S_ENTRY_TYPE_MISMATCH = 1922;
3364
22443365/// Not all object UUIDs could be exported to the specified entry.
22453366pub const RPC_S_NOT_ALL_OBJS_EXPORTED = 1923;
3367
22463368/// Interface could not be exported to the specified entry.
22473369pub const RPC_S_INTERFACE_NOT_EXPORTED = 1924;
3370
22483371/// The specified profile entry could not be added.
22493372pub const RPC_S_PROFILE_NOT_ADDED = 1925;
3373
22503374/// The specified profile element could not be added.
22513375pub const RPC_S_PRF_ELT_NOT_ADDED = 1926;
3376
22523377/// The specified profile element could not be removed.
22533378pub const RPC_S_PRF_ELT_NOT_REMOVED = 1927;
3379
22543380/// The group element could not be added.
22553381pub const RPC_S_GRP_ELT_NOT_ADDED = 1928;
3382
22563383/// The group element could not be removed.
22573384pub const RPC_S_GRP_ELT_NOT_REMOVED = 1929;
3385
22583386/// The printer driver is not compatible with a policy enabled on your computer that blocks NT 4.0 drivers.
22593387pub const KM_DRIVER_BLOCKED = 1930;
3388
22603389/// The context has expired and can no longer be used.
22613390pub const CONTEXT_EXPIRED = 1931;
3391
22623392/// The current user's delegated trust creation quota has been exceeded.
22633393pub const PER_USER_TRUST_QUOTA_EXCEEDED = 1932;
3394
22643395/// The total delegated trust creation quota has been exceeded.
22653396pub const ALL_USER_TRUST_QUOTA_EXCEEDED = 1933;
3397
22663398/// The current user's delegated trust deletion quota has been exceeded.
22673399pub const USER_DELETE_TRUST_QUOTA_EXCEEDED = 1934;
3400
22683401/// The computer you are signing into is protected by an authentication firewall. The specified account is not allowed to authenticate to the computer.
22693402pub const AUTHENTICATION_FIREWALL_FAILED = 1935;
3403
22703404/// Remote connections to the Print Spooler are blocked by a policy set on your machine.
22713405pub const REMOTE_PRINT_CONNECTIONS_BLOCKED = 1936;
3406
22723407/// Authentication failed because NTLM authentication has been disabled.
22733408pub const NTLM_BLOCKED = 1937;
3409
22743410/// Logon Failure: EAS policy requires that the user change their password before this operation can be performed.
22753411pub const PASSWORD_CHANGE_REQUIRED = 1938;
3412
22763413/// The pixel format is invalid.
22773414pub const INVALID_PIXEL_FORMAT = 2000;
3415
22783416/// The specified driver is invalid.
22793417pub const BAD_DRIVER = 2001;
3418
22803419/// The window style or class attribute is invalid for this operation.
22813420pub const INVALID_WINDOW_STYLE = 2002;
3421
22823422/// The requested metafile operation is not supported.
22833423pub const METAFILE_NOT_SUPPORTED = 2003;
3424
22843425/// The requested transformation operation is not supported.
22853426pub const TRANSFORM_NOT_SUPPORTED = 2004;
3427
22863428/// The requested clipping operation is not supported.
22873429pub const CLIPPING_NOT_SUPPORTED = 2005;
3430
22883431/// The specified color management module is invalid.
22893432pub const INVALID_CMM = 2010;
3433
22903434/// The specified color profile is invalid.
22913435pub const INVALID_PROFILE = 2011;
3436
22923437/// The specified tag was not found.
22933438pub const TAG_NOT_FOUND = 2012;
3439
22943440/// A required tag is not present.
22953441pub const TAG_NOT_PRESENT = 2013;
3442
22963443/// The specified tag is already present.
22973444pub const DUPLICATE_TAG = 2014;
3445
22983446/// The specified color profile is not associated with the specified device.
22993447pub const PROFILE_NOT_ASSOCIATED_WITH_DEVICE = 2015;
3448
23003449/// The specified color profile was not found.
23013450pub const PROFILE_NOT_FOUND = 2016;
3451
23023452/// The specified color space is invalid.
23033453pub const INVALID_COLORSPACE = 2017;
3454
23043455/// Image Color Management is not enabled.
23053456pub const ICM_NOT_ENABLED = 2018;
3457
23063458/// There was an error while deleting the color transform.
23073459pub const DELETING_ICM_XFORM = 2019;
3460
23083461/// The specified color transform is invalid.
23093462pub const INVALID_TRANSFORM = 2020;
3463
23103464/// The specified transform does not match the bitmap's color space.
23113465pub const COLORSPACE_MISMATCH = 2021;
3466
23123467/// The specified named color index is not present in the profile.
23133468pub const INVALID_COLORINDEX = 2022;
3469
23143470/// The specified profile is intended for a device of a different type than the specified device.
23153471pub const PROFILE_DOES_NOT_MATCH_DEVICE = 2023;
3472
23163473/// The network connection was made successfully, but the user had to be prompted for a password other than the one originally specified.
23173474pub const CONNECTED_OTHER_PASSWORD = 2108;
3475
23183476/// The network connection was made successfully using default credentials.
23193477pub const CONNECTED_OTHER_PASSWORD_DEFAULT = 2109;
3478
23203479/// The specified username is invalid.
23213480pub const BAD_USERNAME = 2202;
3481
23223482/// This network connection does not exist.
23233483pub const NOT_CONNECTED = 2250;
3484
23243485/// This network connection has files open or requests pending.
23253486pub const OPEN_FILES = 2401;
3487
23263488/// Active connections still exist.
23273489pub const ACTIVE_CONNECTIONS = 2402;
3490
23283491/// The device is in use by an active process and cannot be disconnected.
23293492pub const DEVICE_IN_USE = 2404;
3493
23303494/// The specified print monitor is unknown.
23313495pub const UNKNOWN_PRINT_MONITOR = 3000;
3496
23323497/// The specified printer driver is currently in use.
23333498pub const PRINTER_DRIVER_IN_USE = 3001;
3499
23343500/// The spool file was not found.
23353501pub const SPOOL_FILE_NOT_FOUND = 3002;
3502
23363503/// A StartDocPrinter call was not issued.
23373504pub const SPL_NO_STARTDOC = 3003;
3505
23383506/// An AddJob call was not issued.
23393507pub const SPL_NO_ADDJOB = 3004;
3508
23403509/// The specified print processor has already been installed.
23413510pub const PRINT_PROCESSOR_ALREADY_INSTALLED = 3005;
3511
23423512/// The specified print monitor has already been installed.
23433513pub const PRINT_MONITOR_ALREADY_INSTALLED = 3006;
3514
23443515/// The specified print monitor does not have the required functions.
23453516pub const INVALID_PRINT_MONITOR = 3007;
3517
23463518/// The specified print monitor is currently in use.
23473519pub const PRINT_MONITOR_IN_USE = 3008;
3520
23483521/// The requested operation is not allowed when there are jobs queued to the printer.
23493522pub const PRINTER_HAS_JOBS_QUEUED = 3009;
3523
23503524/// The requested operation is successful. Changes will not be effective until the system is rebooted.
23513525pub const SUCCESS_REBOOT_REQUIRED = 3010;
3526
23523527/// The requested operation is successful. Changes will not be effective until the service is restarted.
23533528pub const SUCCESS_RESTART_REQUIRED = 3011;
3529
23543530/// No printers were found.
23553531pub const PRINTER_NOT_FOUND = 3012;
3532
23563533/// The printer driver is known to be unreliable.
23573534pub const PRINTER_DRIVER_WARNED = 3013;
3535
23583536/// The printer driver is known to harm the system.
23593537pub const PRINTER_DRIVER_BLOCKED = 3014;
3538
23603539/// The specified printer driver package is currently in use.
23613540pub const PRINTER_DRIVER_PACKAGE_IN_USE = 3015;
3541
23623542/// Unable to find a core driver package that is required by the printer driver package.
23633543pub const CORE_DRIVER_PACKAGE_NOT_FOUND = 3016;
3544
23643545/// The requested operation failed. A system reboot is required to roll back changes made.
23653546pub const FAIL_REBOOT_REQUIRED = 3017;
3547
23663548/// The requested operation failed. A system reboot has been initiated to roll back changes made.
23673549pub const FAIL_REBOOT_INITIATED = 3018;
3550
23683551/// The specified printer driver was not found on the system and needs to be downloaded.
23693552pub const PRINTER_DRIVER_DOWNLOAD_NEEDED = 3019;
3553
23703554/// The requested print job has failed to print. A print system update requires the job to be resubmitted.
23713555pub const PRINT_JOB_RESTART_REQUIRED = 3020;
3556
23723557/// The printer driver does not contain a valid manifest, or contains too many manifests.
23733558pub const INVALID_PRINTER_DRIVER_MANIFEST = 3021;
3559
23743560/// The specified printer cannot be shared.
23753561pub const PRINTER_NOT_SHAREABLE = 3022;
3562
23763563/// The operation was paused.
23773564pub const REQUEST_PAUSED = 3050;
3565
23783566/// Reissue the given operation as a cached IO operation.
23793567pub const IO_REISSUE_AS_CACHED = 3950;
std/os/windows/index.zig+113-65
......@@ -1,33 +1,59 @@
11pub const ERROR = @import("error.zig");
22
3pub extern "advapi32" stdcallcc fn CryptAcquireContextA(phProv: &HCRYPTPROV, pszContainer: ?LPCSTR,
4 pszProvider: ?LPCSTR, dwProvType: DWORD, dwFlags: DWORD) BOOL;
3pub extern "advapi32" stdcallcc fn CryptAcquireContextA(
4 phProv: &HCRYPTPROV,
5 pszContainer: ?LPCSTR,
6 pszProvider: ?LPCSTR,
7 dwProvType: DWORD,
8 dwFlags: DWORD,
9) BOOL;
510
611pub extern "advapi32" stdcallcc fn CryptReleaseContext(hProv: HCRYPTPROV, dwFlags: DWORD) BOOL;
712
813pub extern "advapi32" stdcallcc fn CryptGenRandom(hProv: HCRYPTPROV, dwLen: DWORD, pbBuffer: &BYTE) BOOL;
914
10
1115pub extern "kernel32" stdcallcc fn CloseHandle(hObject: HANDLE) BOOL;
1216
13pub extern "kernel32" stdcallcc fn CreateDirectoryA(lpPathName: LPCSTR,
14 lpSecurityAttributes: ?&SECURITY_ATTRIBUTES) BOOL;
15
16pub extern "kernel32" stdcallcc fn CreateFileA(lpFileName: LPCSTR, dwDesiredAccess: DWORD,
17 dwShareMode: DWORD, lpSecurityAttributes: ?LPSECURITY_ATTRIBUTES, dwCreationDisposition: DWORD,
18 dwFlagsAndAttributes: DWORD, hTemplateFile: ?HANDLE) HANDLE;
19
20pub extern "kernel32" stdcallcc fn CreatePipe(hReadPipe: &HANDLE, hWritePipe: &HANDLE,
21 lpPipeAttributes: &const SECURITY_ATTRIBUTES, nSize: DWORD) BOOL;
22
23pub extern "kernel32" stdcallcc fn CreateProcessA(lpApplicationName: ?LPCSTR, lpCommandLine: LPSTR,
24 lpProcessAttributes: ?&SECURITY_ATTRIBUTES, lpThreadAttributes: ?&SECURITY_ATTRIBUTES, bInheritHandles: BOOL,
25 dwCreationFlags: DWORD, lpEnvironment: ?&c_void, lpCurrentDirectory: ?LPCSTR, lpStartupInfo: &STARTUPINFOA,
26 lpProcessInformation: &PROCESS_INFORMATION) BOOL;
27
28pub extern "kernel32" stdcallcc fn CreateSymbolicLinkA(lpSymlinkFileName: LPCSTR, lpTargetFileName: LPCSTR,
29 dwFlags: DWORD) BOOLEAN;
30
17pub extern "kernel32" stdcallcc fn CreateDirectoryA(
18 lpPathName: LPCSTR,
19 lpSecurityAttributes: ?&SECURITY_ATTRIBUTES,
20) BOOL;
21
22pub extern "kernel32" stdcallcc fn CreateFileA(
23 lpFileName: LPCSTR,
24 dwDesiredAccess: DWORD,
25 dwShareMode: DWORD,
26 lpSecurityAttributes: ?LPSECURITY_ATTRIBUTES,
27 dwCreationDisposition: DWORD,
28 dwFlagsAndAttributes: DWORD,
29 hTemplateFile: ?HANDLE,
30) HANDLE;
31
32pub extern "kernel32" stdcallcc fn CreatePipe(
33 hReadPipe: &HANDLE,
34 hWritePipe: &HANDLE,
35 lpPipeAttributes: &const SECURITY_ATTRIBUTES,
36 nSize: DWORD,
37) BOOL;
38
39pub extern "kernel32" stdcallcc fn CreateProcessA(
40 lpApplicationName: ?LPCSTR,
41 lpCommandLine: LPSTR,
42 lpProcessAttributes: ?&SECURITY_ATTRIBUTES,
43 lpThreadAttributes: ?&SECURITY_ATTRIBUTES,
44 bInheritHandles: BOOL,
45 dwCreationFlags: DWORD,
46 lpEnvironment: ?&c_void,
47 lpCurrentDirectory: ?LPCSTR,
48 lpStartupInfo: &STARTUPINFOA,
49 lpProcessInformation: &PROCESS_INFORMATION,
50) BOOL;
51
52pub extern "kernel32" stdcallcc fn CreateSymbolicLinkA(
53 lpSymlinkFileName: LPCSTR,
54 lpTargetFileName: LPCSTR,
55 dwFlags: DWORD,
56) BOOLEAN;
3157
3258pub extern "kernel32" stdcallcc fn CreateThread(lpThreadAttributes: ?LPSECURITY_ATTRIBUTES, dwStackSize: SIZE_T, lpStartAddress: LPTHREAD_START_ROUTINE, lpParameter: ?LPVOID, dwCreationFlags: DWORD, lpThreadId: ?LPDWORD) ?HANDLE;
3359
......@@ -55,12 +81,19 @@ pub extern "kernel32" stdcallcc fn GetModuleFileNameA(hModule: ?HMODULE, lpFilen
5581
5682pub extern "kernel32" stdcallcc fn GetLastError() DWORD;
5783
58pub extern "kernel32" stdcallcc fn GetFileInformationByHandleEx(in_hFile: HANDLE,
59 in_FileInformationClass: FILE_INFO_BY_HANDLE_CLASS, out_lpFileInformation: &c_void,
60 in_dwBufferSize: DWORD) BOOL;
61
62pub extern "kernel32" stdcallcc fn GetFinalPathNameByHandleA(hFile: HANDLE, lpszFilePath: LPSTR,
63 cchFilePath: DWORD, dwFlags: DWORD) DWORD;
84pub extern "kernel32" stdcallcc fn GetFileInformationByHandleEx(
85 in_hFile: HANDLE,
86 in_FileInformationClass: FILE_INFO_BY_HANDLE_CLASS,
87 out_lpFileInformation: &c_void,
88 in_dwBufferSize: DWORD,
89) BOOL;
90
91pub extern "kernel32" stdcallcc fn GetFinalPathNameByHandleA(
92 hFile: HANDLE,
93 lpszFilePath: LPSTR,
94 cchFilePath: DWORD,
95 dwFlags: DWORD,
96) DWORD;
6497
6598pub extern "kernel32" stdcallcc fn GetProcessHeap() ?HANDLE;
6699
......@@ -80,21 +113,32 @@ pub extern "kernel32" stdcallcc fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBy
80113
81114pub extern "kernel32" stdcallcc fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: &c_void) BOOL;
82115
83pub extern "kernel32" stdcallcc fn MoveFileExA(lpExistingFileName: LPCSTR, lpNewFileName: LPCSTR,
84 dwFlags: DWORD) BOOL;
85
116pub extern "kernel32" stdcallcc fn MoveFileExA(
117 lpExistingFileName: LPCSTR,
118 lpNewFileName: LPCSTR,
119 dwFlags: DWORD,
120) BOOL;
121
86122pub extern "kernel32" stdcallcc fn QueryPerformanceCounter(lpPerformanceCount: &LARGE_INTEGER) BOOL;
87123
88124pub extern "kernel32" stdcallcc fn QueryPerformanceFrequency(lpFrequency: &LARGE_INTEGER) BOOL;
89125
90126pub extern "kernel32" stdcallcc fn PathFileExists(pszPath: ?LPCTSTR) BOOL;
91127
92pub extern "kernel32" stdcallcc fn ReadFile(in_hFile: HANDLE, out_lpBuffer: &c_void,
93 in_nNumberOfBytesToRead: DWORD, out_lpNumberOfBytesRead: &DWORD,
94 in_out_lpOverlapped: ?&OVERLAPPED) BOOL;
95
96pub extern "kernel32" stdcallcc fn SetFilePointerEx(in_fFile: HANDLE, in_liDistanceToMove: LARGE_INTEGER,
97 out_opt_ldNewFilePointer: ?&LARGE_INTEGER, in_dwMoveMethod: DWORD) BOOL;
128pub extern "kernel32" stdcallcc fn ReadFile(
129 in_hFile: HANDLE,
130 out_lpBuffer: &c_void,
131 in_nNumberOfBytesToRead: DWORD,
132 out_lpNumberOfBytesRead: &DWORD,
133 in_out_lpOverlapped: ?&OVERLAPPED,
134) BOOL;
135
136pub extern "kernel32" stdcallcc fn SetFilePointerEx(
137 in_fFile: HANDLE,
138 in_liDistanceToMove: LARGE_INTEGER,
139 out_opt_ldNewFilePointer: ?&LARGE_INTEGER,
140 in_dwMoveMethod: DWORD,
141) BOOL;
98142
99143pub extern "kernel32" stdcallcc fn SetHandleInformation(hObject: HANDLE, dwMask: DWORD, dwFlags: DWORD) BOOL;
100144
......@@ -104,14 +148,18 @@ pub extern "kernel32" stdcallcc fn TerminateProcess(hProcess: HANDLE, uExitCode:
104148
105149pub extern "kernel32" stdcallcc fn WaitForSingleObject(hHandle: HANDLE, dwMilliseconds: DWORD) DWORD;
106150
107pub extern "kernel32" stdcallcc fn WriteFile(in_hFile: HANDLE, in_lpBuffer: &const c_void,
108 in_nNumberOfBytesToWrite: DWORD, out_lpNumberOfBytesWritten: ?&DWORD,
109 in_out_lpOverlapped: ?&OVERLAPPED) BOOL;
151pub extern "kernel32" stdcallcc fn WriteFile(
152 in_hFile: HANDLE,
153 in_lpBuffer: &const c_void,
154 in_nNumberOfBytesToWrite: DWORD,
155 out_lpNumberOfBytesWritten: ?&DWORD,
156 in_out_lpOverlapped: ?&OVERLAPPED,
157) BOOL;
110158
111159//TODO: call unicode versions instead of relying on ANSI code page
112160pub extern "kernel32" stdcallcc fn LoadLibraryA(lpLibFileName: LPCSTR) ?HMODULE;
113161
114pub extern "kernel32" stdcallcc fn FreeLibrary(hModule: HMODULE) BOOL;
162pub extern "kernel32" stdcallcc fn FreeLibrary(hModule: HMODULE) BOOL;
115163
116164pub extern "user32" stdcallcc fn MessageBoxA(hWnd: ?HANDLE, lpText: ?LPCTSTR, lpCaption: ?LPCTSTR, uType: UINT) c_int;
117165
......@@ -176,49 +224,51 @@ pub const MAX_PATH = 260;
176224
177225// TODO issue #305
178226pub const FILE_INFO_BY_HANDLE_CLASS = u32;
179pub const FileBasicInfo = 0;
180pub const FileStandardInfo = 1;
181pub const FileNameInfo = 2;
182pub const FileRenameInfo = 3;
183pub const FileDispositionInfo = 4;
184pub const FileAllocationInfo = 5;
185pub const FileEndOfFileInfo = 6;
186pub const FileStreamInfo = 7;
187pub const FileCompressionInfo = 8;
188pub const FileAttributeTagInfo = 9;
189pub const FileIdBothDirectoryInfo = 10;
190pub const FileIdBothDirectoryRestartInfo = 11;
191pub const FileIoPriorityHintInfo = 12;
192pub const FileRemoteProtocolInfo = 13;
193pub const FileFullDirectoryInfo = 14;
194pub const FileFullDirectoryRestartInfo = 15;
195pub const FileStorageInfo = 16;
196pub const FileAlignmentInfo = 17;
197pub const FileIdInfo = 18;
198pub const FileIdExtdDirectoryInfo = 19;
199pub const FileIdExtdDirectoryRestartInfo = 20;
227pub const FileBasicInfo = 0;
228pub const FileStandardInfo = 1;
229pub const FileNameInfo = 2;
230pub const FileRenameInfo = 3;
231pub const FileDispositionInfo = 4;
232pub const FileAllocationInfo = 5;
233pub const FileEndOfFileInfo = 6;
234pub const FileStreamInfo = 7;
235pub const FileCompressionInfo = 8;
236pub const FileAttributeTagInfo = 9;
237pub const FileIdBothDirectoryInfo = 10;
238pub const FileIdBothDirectoryRestartInfo = 11;
239pub const FileIoPriorityHintInfo = 12;
240pub const FileRemoteProtocolInfo = 13;
241pub const FileFullDirectoryInfo = 14;
242pub const FileFullDirectoryRestartInfo = 15;
243pub const FileStorageInfo = 16;
244pub const FileAlignmentInfo = 17;
245pub const FileIdInfo = 18;
246pub const FileIdExtdDirectoryInfo = 19;
247pub const FileIdExtdDirectoryRestartInfo = 20;
200248
201249pub const FILE_NAME_INFO = extern struct {
202250 FileNameLength: DWORD,
203251 FileName: [1]WCHAR,
204252};
205253
206
207254/// Return the normalized drive name. This is the default.
208255pub const FILE_NAME_NORMALIZED = 0x0;
256
209257/// Return the opened file name (not normalized).
210258pub const FILE_NAME_OPENED = 0x8;
211259
212260/// Return the path with the drive letter. This is the default.
213261pub const VOLUME_NAME_DOS = 0x0;
262
214263/// Return the path with a volume GUID path instead of the drive name.
215264pub const VOLUME_NAME_GUID = 0x1;
265
216266/// Return the path with no drive information.
217267pub const VOLUME_NAME_NONE = 0x4;
268
218269/// Return the path with the volume device path.
219270pub const VOLUME_NAME_NT = 0x2;
220271
221
222272pub const SECURITY_ATTRIBUTES = extern struct {
223273 nLength: DWORD,
224274 lpSecurityDescriptor: ?&c_void,
......@@ -227,7 +277,6 @@ pub const SECURITY_ATTRIBUTES = extern struct {
227277pub const PSECURITY_ATTRIBUTES = &SECURITY_ATTRIBUTES;
228278pub const LPSECURITY_ATTRIBUTES = &SECURITY_ATTRIBUTES;
229279
230
231280pub const GENERIC_READ = 0x80000000;
232281pub const GENERIC_WRITE = 0x40000000;
233282pub const GENERIC_EXECUTE = 0x20000000;
......@@ -243,7 +292,6 @@ pub const OPEN_ALWAYS = 4;
243292pub const OPEN_EXISTING = 3;
244293pub const TRUNCATE_EXISTING = 5;
245294
246
247295pub const FILE_ATTRIBUTE_ARCHIVE = 0x20;
248296pub const FILE_ATTRIBUTE_ENCRYPTED = 0x4000;
249297pub const FILE_ATTRIBUTE_HIDDEN = 0x2;
std/os/windows/util.zig+18-19
......@@ -7,7 +7,7 @@ const mem = std.mem;
77const BufMap = std.BufMap;
88const cstr = std.cstr;
99
10pub const WaitError = error {
10pub const WaitError = error{
1111 WaitAbandoned,
1212 WaitTimeOut,
1313 Unexpected,
......@@ -33,7 +33,7 @@ pub fn windowsClose(handle: windows.HANDLE) void {
3333 assert(windows.CloseHandle(handle) != 0);
3434}
3535
36pub const WriteError = error {
36pub const WriteError = error{
3737 SystemResources,
3838 OperationAborted,
3939 IoPending,
......@@ -68,20 +68,18 @@ pub fn windowsIsCygwinPty(handle: windows.HANDLE) bool {
6868 const size = @sizeOf(windows.FILE_NAME_INFO);
6969 var name_info_bytes align(@alignOf(windows.FILE_NAME_INFO)) = []u8{0} ** (size + windows.MAX_PATH);
7070
71 if (windows.GetFileInformationByHandleEx(handle, windows.FileNameInfo,
72 @ptrCast(&c_void, &name_info_bytes[0]), u32(name_info_bytes.len)) == 0)
73 {
71 if (windows.GetFileInformationByHandleEx(handle, windows.FileNameInfo, @ptrCast(&c_void, &name_info_bytes[0]), u32(name_info_bytes.len)) == 0) {
7472 return true;
7573 }
7674
7775 const name_info = @ptrCast(&const windows.FILE_NAME_INFO, &name_info_bytes[0]);
7876 const name_bytes = name_info_bytes[size..size + usize(name_info.FileNameLength)];
79 const name_wide = ([]u16)(name_bytes);
80 return mem.indexOf(u16, name_wide, []u16{'m','s','y','s','-'}) != null or
81 mem.indexOf(u16, name_wide, []u16{'-','p','t','y'}) != null;
77 const name_wide = ([]u16)(name_bytes);
78 return mem.indexOf(u16, name_wide, []u16{ 'm', 's', 'y', 's', '-' }) != null or
79 mem.indexOf(u16, name_wide, []u16{ '-', 'p', 't', 'y' }) != null;
8280}
8381
84pub const OpenError = error {
82pub const OpenError = error{
8583 SharingViolation,
8684 PathAlreadyExists,
8785 FileNotFound,
......@@ -92,15 +90,18 @@ pub const OpenError = error {
9290};
9391
9492/// `file_path` needs to be copied in memory to add a null terminating byte, hence the allocator.
95pub fn windowsOpen(allocator: &mem.Allocator, file_path: []const u8, desired_access: windows.DWORD, share_mode: windows.DWORD,
96 creation_disposition: windows.DWORD, flags_and_attrs: windows.DWORD)
97 OpenError!windows.HANDLE
98{
93pub fn windowsOpen(
94 allocator: &mem.Allocator,
95 file_path: []const u8,
96 desired_access: windows.DWORD,
97 share_mode: windows.DWORD,
98 creation_disposition: windows.DWORD,
99 flags_and_attrs: windows.DWORD,
100) OpenError!windows.HANDLE {
99101 const path_with_null = try cstr.addNullByte(allocator, file_path);
100102 defer allocator.free(path_with_null);
101103
102 const result = windows.CreateFileA(path_with_null.ptr, desired_access, share_mode, null, creation_disposition,
103 flags_and_attrs, null);
104 const result = windows.CreateFileA(path_with_null.ptr, desired_access, share_mode, null, creation_disposition, flags_and_attrs, null);
104105
105106 if (result == windows.INVALID_HANDLE_VALUE) {
106107 const err = windows.GetLastError();
......@@ -156,18 +157,16 @@ pub fn windowsLoadDll(allocator: &mem.Allocator, dll_path: []const u8) !windows.
156157}
157158
158159pub fn windowsUnloadDll(hModule: windows.HMODULE) void {
159 assert(windows.FreeLibrary(hModule)!= 0);
160 assert(windows.FreeLibrary(hModule) != 0);
160161}
161162
162
163163test "InvalidDll" {
164164 if (builtin.os != builtin.Os.windows) return;
165165
166166 const DllName = "asdf.dll";
167167 const allocator = std.debug.global_allocator;
168 const handle = os.windowsLoadDll(allocator, DllName) catch |err| {
168 const handle = os.windowsLoadDll(allocator, DllName) catch |err| {
169169 assert(err == error.DllNotFound);
170170 return;
171171 };
172172}
173
std/os/zen.zig+76-62
......@@ -3,35 +3,35 @@
33//////////////////////////
44
55pub const Message = struct {
6 sender: MailboxId,
6 sender: MailboxId,
77 receiver: MailboxId,
8 type: usize,
9 payload: usize,
8 type: usize,
9 payload: usize,
1010
1111 pub fn from(mailbox_id: &const MailboxId) Message {
12 return Message {
13 .sender = MailboxId.Undefined,
12 return Message{
13 .sender = MailboxId.Undefined,
1414 .receiver = *mailbox_id,
15 .type = 0,
16 .payload = 0,
15 .type = 0,
16 .payload = 0,
1717 };
1818 }
1919
2020 pub fn to(mailbox_id: &const MailboxId, msg_type: usize) Message {
21 return Message {
22 .sender = MailboxId.This,
21 return Message{
22 .sender = MailboxId.This,
2323 .receiver = *mailbox_id,
24 .type = msg_type,
25 .payload = 0,
24 .type = msg_type,
25 .payload = 0,
2626 };
2727 }
2828
2929 pub fn withData(mailbox_id: &const MailboxId, msg_type: usize, payload: usize) Message {
30 return Message {
31 .sender = MailboxId.This,
30 return Message{
31 .sender = MailboxId.This,
3232 .receiver = *mailbox_id,
33 .type = msg_type,
34 .payload = payload,
33 .type = msg_type,
34 .payload = payload,
3535 };
3636 }
3737};
......@@ -40,27 +40,25 @@ pub const MailboxId = union(enum) {
4040 Undefined,
4141 This,
4242 Kernel,
43 Port: u16,
43 Port: u16,
4444 Thread: u16,
4545};
4646
47
4847//////////////////////////////////////
4948//// Ports reserved for servers ////
5049//////////////////////////////////////
5150
5251pub const Server = struct {
53 pub const Keyboard = MailboxId { .Port = 0 };
54 pub const Terminal = MailboxId { .Port = 1 };
52 pub const Keyboard = MailboxId{ .Port = 0 };
53 pub const Terminal = MailboxId{ .Port = 1 };
5554};
5655
57
5856////////////////////////
5957//// POSIX things ////
6058////////////////////////
6159
6260// Standard streams.
63pub const STDIN_FILENO = 0;
61pub const STDIN_FILENO = 0;
6462pub const STDOUT_FILENO = 1;
6563pub const STDERR_FILENO = 2;
6664
......@@ -101,26 +99,24 @@ pub fn write(fd: i32, buf: &const u8, count: usize) usize {
10199 return count;
102100}
103101
104
105102///////////////////////////
106103//// Syscall numbers ////
107104///////////////////////////
108105
109106pub const Syscall = enum(usize) {
110 exit = 0,
111 createPort = 1,
112 send = 2,
113 receive = 3,
114 subscribeIRQ = 4,
115 inb = 5,
116 map = 6,
117 createThread = 7,
107 exit = 0,
108 createPort = 1,
109 send = 2,
110 receive = 3,
111 subscribeIRQ = 4,
112 inb = 5,
113 map = 6,
114 createThread = 7,
118115 createProcess = 8,
119 wait = 9,
120 portReady = 10,
116 wait = 9,
117 portReady = 10,
121118};
122119
123
124120////////////////////
125121//// Syscalls ////
126122////////////////////
......@@ -157,7 +153,7 @@ pub fn map(v_addr: usize, p_addr: usize, size: usize, writable: bool) bool {
157153 return syscall4(Syscall.map, v_addr, p_addr, size, usize(writable)) != 0;
158154}
159155
160pub fn createThread(function: fn()void) u16 {
156pub fn createThread(function: fn() void) u16 {
161157 return u16(syscall1(Syscall.createThread, @ptrToInt(function)));
162158}
163159
......@@ -180,66 +176,84 @@ pub fn portReady(port: u16) bool {
180176inline fn syscall0(number: Syscall) usize {
181177 return asm volatile ("int $0x80"
182178 : [ret] "={eax}" (-> usize)
183 : [number] "{eax}" (number));
179 : [number] "{eax}" (number)
180 );
184181}
185182
186183inline fn syscall1(number: Syscall, arg1: usize) usize {
187184 return asm volatile ("int $0x80"
188185 : [ret] "={eax}" (-> usize)
189186 : [number] "{eax}" (number),
190 [arg1] "{ecx}" (arg1));
187 [arg1] "{ecx}" (arg1)
188 );
191189}
192190
193191inline fn syscall2(number: Syscall, arg1: usize, arg2: usize) usize {
194192 return asm volatile ("int $0x80"
195193 : [ret] "={eax}" (-> usize)
196194 : [number] "{eax}" (number),
197 [arg1] "{ecx}" (arg1),
198 [arg2] "{edx}" (arg2));
195 [arg1] "{ecx}" (arg1),
196 [arg2] "{edx}" (arg2)
197 );
199198}
200199
201200inline fn syscall3(number: Syscall, arg1: usize, arg2: usize, arg3: usize) usize {
202201 return asm volatile ("int $0x80"
203202 : [ret] "={eax}" (-> usize)
204203 : [number] "{eax}" (number),
205 [arg1] "{ecx}" (arg1),
206 [arg2] "{edx}" (arg2),
207 [arg3] "{ebx}" (arg3));
204 [arg1] "{ecx}" (arg1),
205 [arg2] "{edx}" (arg2),
206 [arg3] "{ebx}" (arg3)
207 );
208208}
209209
210210inline fn syscall4(number: Syscall, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
211211 return asm volatile ("int $0x80"
212212 : [ret] "={eax}" (-> usize)
213213 : [number] "{eax}" (number),
214 [arg1] "{ecx}" (arg1),
215 [arg2] "{edx}" (arg2),
216 [arg3] "{ebx}" (arg3),
217 [arg4] "{esi}" (arg4));
214 [arg1] "{ecx}" (arg1),
215 [arg2] "{edx}" (arg2),
216 [arg3] "{ebx}" (arg3),
217 [arg4] "{esi}" (arg4)
218 );
218219}
219220
220inline fn syscall5(number: Syscall, arg1: usize, arg2: usize, arg3: usize,
221 arg4: usize, arg5: usize) usize
222{
221inline fn syscall5(
222 number: Syscall,
223 arg1: usize,
224 arg2: usize,
225 arg3: usize,
226 arg4: usize,
227 arg5: usize,
228) usize {
223229 return asm volatile ("int $0x80"
224230 : [ret] "={eax}" (-> usize)
225231 : [number] "{eax}" (number),
226 [arg1] "{ecx}" (arg1),
227 [arg2] "{edx}" (arg2),
228 [arg3] "{ebx}" (arg3),
229 [arg4] "{esi}" (arg4),
230 [arg5] "{edi}" (arg5));
232 [arg1] "{ecx}" (arg1),
233 [arg2] "{edx}" (arg2),
234 [arg3] "{ebx}" (arg3),
235 [arg4] "{esi}" (arg4),
236 [arg5] "{edi}" (arg5)
237 );
231238}
232239
233inline fn syscall6(number: Syscall, arg1: usize, arg2: usize, arg3: usize,
234 arg4: usize, arg5: usize, arg6: usize) usize
235{
240inline fn syscall6(
241 number: Syscall,
242 arg1: usize,
243 arg2: usize,
244 arg3: usize,
245 arg4: usize,
246 arg5: usize,
247 arg6: usize,
248) usize {
236249 return asm volatile ("int $0x80"
237250 : [ret] "={eax}" (-> usize)
238251 : [number] "{eax}" (number),
239 [arg1] "{ecx}" (arg1),
240 [arg2] "{edx}" (arg2),
241 [arg3] "{ebx}" (arg3),
242 [arg4] "{esi}" (arg4),
243 [arg5] "{edi}" (arg5),
244 [arg6] "{ebp}" (arg6));
252 [arg1] "{ecx}" (arg1),
253 [arg2] "{edx}" (arg2),
254 [arg3] "{ebx}" (arg3),
255 [arg4] "{esi}" (arg4),
256 [arg5] "{edi}" (arg5),
257 [arg6] "{ebp}" (arg6)
258 );
245259}
std/rand/index.zig+54-38
......@@ -69,7 +69,7 @@ pub const Random = struct {
6969 break :x start;
7070 } else x: {
7171 // Can't overflow because the range is over signed ints
72 break :x math.negateCast(value - end_uint) catch unreachable;
72 break :x math.negateCast(value - end_uint) catch unreachable;
7373 };
7474 return result;
7575 } else {
......@@ -156,7 +156,7 @@ const SplitMix64 = struct {
156156 s: u64,
157157
158158 pub fn init(seed: u64) SplitMix64 {
159 return SplitMix64 { .s = seed };
159 return SplitMix64{ .s = seed };
160160 }
161161
162162 pub fn next(self: &SplitMix64) u64 {
......@@ -172,7 +172,7 @@ const SplitMix64 = struct {
172172test "splitmix64 sequence" {
173173 var r = SplitMix64.init(0xaeecf86f7878dd75);
174174
175 const seq = []const u64 {
175 const seq = []const u64{
176176 0x5dbd39db0178eb44,
177177 0xa9900fb66b397da3,
178178 0x5c1a28b1aeebcf5c,
......@@ -198,8 +198,8 @@ pub const Pcg = struct {
198198 i: u64,
199199
200200 pub fn init(init_s: u64) Pcg {
201 var pcg = Pcg {
202 .random = Random { .fillFn = fill },
201 var pcg = Pcg{
202 .random = Random{ .fillFn = fill },
203203 .s = undefined,
204204 .i = undefined,
205205 };
......@@ -265,7 +265,7 @@ test "pcg sequence" {
265265 const s1: u64 = 0x84e9c579ef59bbf7;
266266 r.seedTwo(s0, s1);
267267
268 const seq = []const u32 {
268 const seq = []const u32{
269269 2881561918,
270270 3063928540,
271271 1199791034,
......@@ -288,8 +288,8 @@ pub const Xoroshiro128 = struct {
288288 s: [2]u64,
289289
290290 pub fn init(init_s: u64) Xoroshiro128 {
291 var x = Xoroshiro128 {
292 .random = Random { .fillFn = fill },
291 var x = Xoroshiro128{
292 .random = Random{ .fillFn = fill },
293293 .s = undefined,
294294 };
295295
......@@ -314,9 +314,9 @@ pub const Xoroshiro128 = struct {
314314 var s0: u64 = 0;
315315 var s1: u64 = 0;
316316
317 const table = []const u64 {
317 const table = []const u64{
318318 0xbeac0467eba5facb,
319 0xd86b048b86aa9922
319 0xd86b048b86aa9922,
320320 };
321321
322322 inline for (table) |entry| {
......@@ -374,7 +374,7 @@ test "xoroshiro sequence" {
374374 r.s[0] = 0xaeecf86f7878dd75;
375375 r.s[1] = 0x01cd153642e72622;
376376
377 const seq1 = []const u64 {
377 const seq1 = []const u64{
378378 0xb0ba0da5bb600397,
379379 0x18a08afde614dccc,
380380 0xa2635b956a31b929,
......@@ -387,10 +387,9 @@ test "xoroshiro sequence" {
387387 std.debug.assert(s == r.next());
388388 }
389389
390
391390 r.jump();
392391
393 const seq2 = []const u64 {
392 const seq2 = []const u64{
394393 0x95344a13556d3e22,
395394 0xb4fb32dafa4d00df,
396395 0xb2011d9ccdcfe2dd,
......@@ -421,8 +420,8 @@ pub const Isaac64 = struct {
421420 i: usize,
422421
423422 pub fn init(init_s: u64) Isaac64 {
424 var isaac = Isaac64 {
425 .random = Random { .fillFn = fill },
423 var isaac = Isaac64{
424 .random = Random{ .fillFn = fill },
426425 .r = undefined,
427426 .m = undefined,
428427 .a = undefined,
......@@ -456,20 +455,20 @@ pub const Isaac64 = struct {
456455 {
457456 var i: usize = 0;
458457 while (i < midpoint) : (i += 4) {
459 self.step( ~(self.a ^ (self.a << 21)), i + 0, 0, midpoint);
460 self.step( self.a ^ (self.a >> 5) , i + 1, 0, midpoint);
461 self.step( self.a ^ (self.a << 12) , i + 2, 0, midpoint);
462 self.step( self.a ^ (self.a >> 33) , i + 3, 0, midpoint);
458 self.step(~(self.a ^ (self.a << 21)), i + 0, 0, midpoint);
459 self.step(self.a ^ (self.a >> 5), i + 1, 0, midpoint);
460 self.step(self.a ^ (self.a << 12), i + 2, 0, midpoint);
461 self.step(self.a ^ (self.a >> 33), i + 3, 0, midpoint);
463462 }
464463 }
465464
466465 {
467466 var i: usize = 0;
468467 while (i < midpoint) : (i += 4) {
469 self.step( ~(self.a ^ (self.a << 21)), i + 0, midpoint, 0);
470 self.step( self.a ^ (self.a >> 5) , i + 1, midpoint, 0);
471 self.step( self.a ^ (self.a << 12) , i + 2, midpoint, 0);
472 self.step( self.a ^ (self.a >> 33) , i + 3, midpoint, 0);
468 self.step(~(self.a ^ (self.a << 21)), i + 0, midpoint, 0);
469 self.step(self.a ^ (self.a >> 5), i + 1, midpoint, 0);
470 self.step(self.a ^ (self.a << 12), i + 2, midpoint, 0);
471 self.step(self.a ^ (self.a >> 33), i + 3, midpoint, 0);
473472 }
474473 }
475474
......@@ -493,7 +492,7 @@ pub const Isaac64 = struct {
493492 self.m[0] = init_s;
494493
495494 // prescrambled golden ratio constants
496 var a = []const u64 {
495 var a = []const u64{
497496 0x647c4677a2884b7c,
498497 0xb9f8b322c73ac862,
499498 0x8c0ea5053d4712a0,
......@@ -513,14 +512,30 @@ pub const Isaac64 = struct {
513512 a[x1] +%= self.m[j + x1];
514513 }
515514
516 a[0] -%= a[4]; a[5] ^= a[7] >> 9; a[7] +%= a[0];
517 a[1] -%= a[5]; a[6] ^= a[0] << 9; a[0] +%= a[1];
518 a[2] -%= a[6]; a[7] ^= a[1] >> 23; a[1] +%= a[2];
519 a[3] -%= a[7]; a[0] ^= a[2] << 15; a[2] +%= a[3];
520 a[4] -%= a[0]; a[1] ^= a[3] >> 14; a[3] +%= a[4];
521 a[5] -%= a[1]; a[2] ^= a[4] << 20; a[4] +%= a[5];
522 a[6] -%= a[2]; a[3] ^= a[5] >> 17; a[5] +%= a[6];
523 a[7] -%= a[3]; a[4] ^= a[6] << 14; a[6] +%= a[7];
515 a[0] -%= a[4];
516 a[5] ^= a[7] >> 9;
517 a[7] +%= a[0];
518 a[1] -%= a[5];
519 a[6] ^= a[0] << 9;
520 a[0] +%= a[1];
521 a[2] -%= a[6];
522 a[7] ^= a[1] >> 23;
523 a[1] +%= a[2];
524 a[3] -%= a[7];
525 a[0] ^= a[2] << 15;
526 a[2] +%= a[3];
527 a[4] -%= a[0];
528 a[1] ^= a[3] >> 14;
529 a[3] +%= a[4];
530 a[5] -%= a[1];
531 a[2] ^= a[4] << 20;
532 a[4] +%= a[5];
533 a[6] -%= a[2];
534 a[3] ^= a[5] >> 17;
535 a[5] +%= a[6];
536 a[7] -%= a[3];
537 a[4] ^= a[6] << 14;
538 a[6] +%= a[7];
524539
525540 comptime var x2: usize = 0;
526541 inline while (x2 < 8) : (x2 += 1) {
......@@ -533,7 +548,7 @@ pub const Isaac64 = struct {
533548 self.a = 0;
534549 self.b = 0;
535550 self.c = 0;
536 self.i = self.r.len; // trigger refill on first value
551 self.i = self.r.len; // trigger refill on first value
537552 }
538553
539554 fn fill(r: &Random, buf: []u8) void {
......@@ -567,7 +582,7 @@ test "isaac64 sequence" {
567582 var r = Isaac64.init(0);
568583
569584 // from reference implementation
570 const seq = []const u64 {
585 const seq = []const u64{
571586 0xf67dfba498e4937c,
572587 0x84a5066a9204f380,
573588 0xfee34bd5f5514dbb,
......@@ -609,7 +624,7 @@ test "Random float" {
609624
610625test "Random scalar" {
611626 var prng = DefaultPrng.init(0);
612 const s = prng .random.scalar(u64);
627 const s = prng.random.scalar(u64);
613628}
614629
615630test "Random bytes" {
......@@ -621,8 +636,8 @@ test "Random bytes" {
621636test "Random shuffle" {
622637 var prng = DefaultPrng.init(0);
623638
624 var seq = []const u8 { 0, 1, 2, 3, 4 };
625 var seen = []bool {false} ** 5;
639 var seq = []const u8{ 0, 1, 2, 3, 4 };
640 var seen = []bool{false} ** 5;
626641
627642 var i: usize = 0;
628643 while (i < 1000) : (i += 1) {
......@@ -639,7 +654,8 @@ test "Random shuffle" {
639654
640655fn sumArray(s: []const u8) u32 {
641656 var r: u32 = 0;
642 for (s) |e| r += e;
657 for (s) |e|
658 r += e;
643659 return r;
644660}
645661
std/rand/ziggurat.zig+23-7
......@@ -64,8 +64,14 @@ pub const ZigTable = struct {
6464};
6565
6666// zigNorInit
67fn ZigTableGen(comptime is_symmetric: bool, comptime r: f64, comptime v: f64, comptime f: fn(f64) f64,
68 comptime f_inv: fn(f64) f64, comptime zero_case: fn(&Random, f64) f64) ZigTable {
67fn ZigTableGen(
68 comptime is_symmetric: bool,
69 comptime r: f64,
70 comptime v: f64,
71 comptime f: fn(f64) f64,
72 comptime f_inv: fn(f64) f64,
73 comptime zero_case: fn(&Random, f64) f64,
74) ZigTable {
6975 var tables: ZigTable = undefined;
7076
7177 tables.is_symmetric = is_symmetric;
......@@ -98,8 +104,12 @@ pub const NormDist = blk: {
98104const norm_r = 3.6541528853610088;
99105const norm_v = 0.00492867323399;
100106
101fn norm_f(x: f64) f64 { return math.exp(-x * x / 2.0); }
102fn norm_f_inv(y: f64) f64 { return math.sqrt(-2.0 * math.ln(y)); }
107fn norm_f(x: f64) f64 {
108 return math.exp(-x * x / 2.0);
109}
110fn norm_f_inv(y: f64) f64 {
111 return math.sqrt(-2.0 * math.ln(y));
112}
103113fn norm_zero_case(random: &Random, u: f64) f64 {
104114 var x: f64 = 1;
105115 var y: f64 = 0;
......@@ -133,9 +143,15 @@ pub const ExpDist = blk: {
133143const exp_r = 7.69711747013104972;
134144const exp_v = 0.0039496598225815571993;
135145
136fn exp_f(x: f64) f64 { return math.exp(-x); }
137fn exp_f_inv(y: f64) f64 { return -math.ln(y); }
138fn exp_zero_case(random: &Random, _: f64) f64 { return exp_r - math.ln(random.float(f64)); }
146fn exp_f(x: f64) f64 {
147 return math.exp(-x);
148}
149fn exp_f_inv(y: f64) f64 {
150 return -math.ln(y);
151}
152fn exp_zero_case(random: &Random, _: f64) f64 {
153 return exp_r - math.ln(random.float(f64));
154}
139155
140156test "ziggurant exp dist sanity" {
141157 var prng = std.rand.DefaultPrng.init(0);
std/segmented_list.zig+3-3
......@@ -5,7 +5,7 @@ const Allocator = std.mem.Allocator;
55// Imagine that `fn at(self: &Self, index: usize) &T` is a customer asking for a box
66// from a warehouse, based on a flat array, boxes ordered from 0 to N - 1.
77// But the warehouse actually stores boxes in shelves of increasing powers of 2 sizes.
8// So when the customer requests a box index, we have to translate it to shelf index
8// So when the customer requests a box index, we have to translate it to shelf index
99// and box index within that shelf. Illustration:
1010//
1111// customer indexes:
......@@ -37,14 +37,14 @@ const Allocator = std.mem.Allocator;
3737// Now we complicate it a little bit further by adding a preallocated shelf, which must be
3838// a power of 2:
3939// prealloc=4
40//
40//
4141// customer indexes:
4242// prealloc: 0 1 2 3
4343// shelf 0: 4 5 6 7 8 9 10 11
4444// shelf 1: 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
4545// shelf 2: 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
4646// ...
47//
47//
4848// warehouse indexes:
4949// prealloc: 0 1 2 3
5050// shelf 0: 0 1 2 3 4 5 6 7
std/sort.zig-1
......@@ -317,7 +317,6 @@ pub fn sort(comptime T: type, items: []T, lessThan: fn(lhs: &const T, rhs: &cons
317317 // 6. merge each A block with any B values that follow, using the cache or the second internal buffer
318318 // 7. sort the second internal buffer if it exists
319319 // 8. redistribute the two internal buffers back into the items
320
321320 var block_size: usize = math.sqrt(iterator.length());
322321 var buffer_size = iterator.length() / block_size + 1;
323322
std/special/bootstrap.zig+6-2
......@@ -27,10 +27,14 @@ extern fn zen_start() noreturn {
2727nakedcc fn _start() noreturn {
2828 switch (builtin.arch) {
2929 builtin.Arch.x86_64 => {
30 argc_ptr = asm ("lea (%%rsp), %[argc]" : [argc] "=r" (-> &usize));
30 argc_ptr = asm ("lea (%%rsp), %[argc]"
31 : [argc] "=r" (-> &usize)
32 );
3133 },
3234 builtin.Arch.i386 => {
33 argc_ptr = asm ("lea (%%esp), %[argc]" : [argc] "=r" (-> &usize));
35 argc_ptr = asm ("lea (%%esp), %[argc]"
36 : [argc] "=r" (-> &usize)
37 );
3438 },
3539 else => @compileError("unsupported arch"),
3640 }
std/special/bootstrap_lib.zig+5-3
......@@ -7,8 +7,10 @@ comptime {
77 @export("_DllMainCRTStartup", _DllMainCRTStartup, builtin.GlobalLinkage.Strong);
88}
99
10stdcallcc fn _DllMainCRTStartup(hinstDLL: std.os.windows.HINSTANCE, fdwReason: std.os.windows.DWORD,
11 lpReserved: std.os.windows.LPVOID) std.os.windows.BOOL
12{
10stdcallcc fn _DllMainCRTStartup(
11 hinstDLL: std.os.windows.HINSTANCE,
12 fdwReason: std.os.windows.DWORD,
13 lpReserved: std.os.windows.LPVOID,
14) std.os.windows.BOOL {
1315 return std.os.windows.TRUE;
1416}
std/special/build_runner.zig+2-4
......@@ -24,7 +24,6 @@ pub fn main() !void {
2424
2525 const allocator = &arena.allocator;
2626
27
2827 // skip my own exe name
2928 _ = arg_it.skip();
3029
......@@ -175,8 +174,7 @@ fn usage(builder: &Builder, already_ran_build: bool, out_stream: var) !void {
175174 try out_stream.print(" (none)\n");
176175 } else {
177176 for (builder.available_options_list.toSliceConst()) |option| {
178 const name = try fmt.allocPrint(allocator,
179 " -D{}=[{}]", option.name, Builder.typeIdName(option.type_id));
177 const name = try fmt.allocPrint(allocator, " -D{}=[{}]", option.name, Builder.typeIdName(option.type_id));
180178 defer allocator.free(name);
181179 try out_stream.print("{s24} {}\n", name, option.description);
182180 }
......@@ -202,7 +200,7 @@ fn usageAndErr(builder: &Builder, already_ran_build: bool, out_stream: var) erro
202200 return error.InvalidArgs;
203201}
204202
205const UnwrapArgError = error {OutOfMemory};
203const UnwrapArgError = error{OutOfMemory};
206204
207205fn unwrapArg(arg: UnwrapArgError![]u8) UnwrapArgError![]u8 {
208206 return arg catch |err| {
std/special/builtin.zig+41-19
......@@ -56,7 +56,8 @@ export fn memmove(dest: ?&u8, src: ?&const u8, n: usize) ?&u8 {
5656comptime {
5757 if (builtin.mode != builtin.Mode.ReleaseFast and
5858 builtin.mode != builtin.Mode.ReleaseSmall and
59 builtin.os != builtin.Os.windows) {
59 builtin.os != builtin.Os.windows)
60 {
6061 @export("__stack_chk_fail", __stack_chk_fail, builtin.GlobalLinkage.Strong);
6162 }
6263 if (builtin.os == builtin.Os.linux and builtin.arch == builtin.Arch.x86_64) {
......@@ -101,15 +102,27 @@ nakedcc fn clone() void {
101102
102103const math = @import("../math/index.zig");
103104
104export fn fmodf(x: f32, y: f32) f32 { return generic_fmod(f32, x, y); }
105export fn fmod(x: f64, y: f64) f64 { return generic_fmod(f64, x, y); }
105export fn fmodf(x: f32, y: f32) f32 {
106 return generic_fmod(f32, x, y);
107}
108export fn fmod(x: f64, y: f64) f64 {
109 return generic_fmod(f64, x, y);
110}
106111
107112// TODO add intrinsics for these (and probably the double version too)
108113// and have the math stuff use the intrinsic. same as @mod and @rem
109export fn floorf(x: f32) f32 { return math.floor(x); }
110export fn ceilf(x: f32) f32 { return math.ceil(x); }
111export fn floor(x: f64) f64 { return math.floor(x); }
112export fn ceil(x: f64) f64 { return math.ceil(x); }
114export fn floorf(x: f32) f32 {
115 return math.floor(x);
116}
117export fn ceilf(x: f32) f32 {
118 return math.ceil(x);
119}
120export fn floor(x: f64) f64 {
121 return math.floor(x);
122}
123export fn ceil(x: f64) f64 {
124 return math.ceil(x);
125}
113126
114127fn generic_fmod(comptime T: type, x: T, y: T) T {
115128 @setRuntimeSafety(false);
......@@ -139,7 +152,10 @@ fn generic_fmod(comptime T: type, x: T, y: T) T {
139152 // normalize x and y
140153 if (ex == 0) {
141154 i = ux << exp_bits;
142 while (i >> bits_minus_1 == 0) : (b: {ex -= 1; break :b i <<= 1;}) {}
155 while (i >> bits_minus_1 == 0) : (b: {
156 ex -= 1;
157 i <<= 1;
158 }) {}
143159 ux <<= log2uint(@bitCast(u32, -ex + 1));
144160 } else {
145161 ux &= @maxValue(uint) >> exp_bits;
......@@ -147,7 +163,10 @@ fn generic_fmod(comptime T: type, x: T, y: T) T {
147163 }
148164 if (ey == 0) {
149165 i = uy << exp_bits;
150 while (i >> bits_minus_1 == 0) : (b: {ey -= 1; break :b i <<= 1;}) {}
166 while (i >> bits_minus_1 == 0) : (b: {
167 ey -= 1;
168 i <<= 1;
169 }) {}
151170 uy <<= log2uint(@bitCast(u32, -ey + 1));
152171 } else {
153172 uy &= @maxValue(uint) >> exp_bits;
......@@ -170,7 +189,10 @@ fn generic_fmod(comptime T: type, x: T, y: T) T {
170189 return 0 * x;
171190 ux = i;
172191 }
173 while (ux >> digits == 0) : (b: {ux <<= 1; break :b ex -= 1;}) {}
192 while (ux >> digits == 0) : (b: {
193 ux <<= 1;
194 ex -= 1;
195 }) {}
174196
175197 // scale result up
176198 if (ex > 0) {
......@@ -298,7 +320,7 @@ export fn sqrt(x: f64) f64 {
298320
299321 // rounding direction
300322 if (ix0 | ix1 != 0) {
301 var z = 1.0 - tiny; // raise inexact
323 var z = 1.0 - tiny; // raise inexact
302324 if (z >= 1.0) {
303325 z = 1.0 + tiny;
304326 if (q1 == 0xFFFFFFFF) {
......@@ -336,13 +358,13 @@ export fn sqrtf(x: f32) f32 {
336358 var ix: i32 = @bitCast(i32, x);
337359
338360 if ((ix & 0x7F800000) == 0x7F800000) {
339 return x * x + x; // sqrt(nan) = nan, sqrt(+inf) = +inf, sqrt(-inf) = snan
361 return x * x + x; // sqrt(nan) = nan, sqrt(+inf) = +inf, sqrt(-inf) = snan
340362 }
341363
342364 // zero
343365 if (ix <= 0) {
344366 if (ix & ~sign == 0) {
345 return x; // sqrt (+-0) = +-0
367 return x; // sqrt (+-0) = +-0
346368 }
347369 if (ix < 0) {
348370 return math.snan(f32);
......@@ -360,20 +382,20 @@ export fn sqrtf(x: f32) f32 {
360382 m -= i - 1;
361383 }
362384
363 m -= 127; // unbias exponent
385 m -= 127; // unbias exponent
364386 ix = (ix & 0x007FFFFF) | 0x00800000;
365387
366 if (m & 1 != 0) { // odd m, double x to even
388 if (m & 1 != 0) { // odd m, double x to even
367389 ix += ix;
368390 }
369391
370 m >>= 1; // m = [m / 2]
392 m >>= 1; // m = [m / 2]
371393
372394 // sqrt(x) bit by bit
373395 ix += ix;
374 var q: i32 = 0; // q = sqrt(x)
396 var q: i32 = 0; // q = sqrt(x)
375397 var s: i32 = 0;
376 var r: i32 = 0x01000000; // r = moving bit right -> left
398 var r: i32 = 0x01000000; // r = moving bit right -> left
377399
378400 while (r != 0) {
379401 const t = s + r;
......@@ -388,7 +410,7 @@ export fn sqrtf(x: f32) f32 {
388410
389411 // floating add to find rounding direction
390412 if (ix != 0) {
391 var z = 1.0 - tiny; // inexact
413 var z = 1.0 - tiny; // inexact
392414 if (z >= 1.0) {
393415 z = 1.0 + tiny;
394416 if (z > 1.0) {
std/special/compiler_rt/comparetf2.zig+25-32
......@@ -38,25 +38,22 @@ pub extern fn __letf2(a: f128, b: f128) c_int {
3838
3939 // If at least one of a and b is positive, we get the same result comparing
4040 // a and b as signed integers as we would with a floating-point compare.
41 return if ((aInt & bInt) >= 0)
42 if (aInt < bInt)
43 LE_LESS
44 else if (aInt == bInt)
45 LE_EQUAL
46 else
47 LE_GREATER
41 return if ((aInt & bInt) >= 0) if (aInt < bInt)
42 LE_LESS
43 else if (aInt == bInt)
44 LE_EQUAL
4845 else
49 // Otherwise, both are negative, so we need to flip the sense of the
50 // comparison to get the correct result. (This assumes a twos- or ones-
51 // complement integer representation; if integers are represented in a
52 // sign-magnitude representation, then this flip is incorrect).
53 if (aInt > bInt)
54 LE_LESS
55 else if (aInt == bInt)
56 LE_EQUAL
57 else
58 LE_GREATER
59 ;
46 LE_GREATER else
47 // Otherwise, both are negative, so we need to flip the sense of the
48 // comparison to get the correct result. (This assumes a twos- or ones-
49 // complement integer representation; if integers are represented in a
50 // sign-magnitude representation, then this flip is incorrect).
51 if (aInt > bInt)
52 LE_LESS
53 else if (aInt == bInt)
54 LE_EQUAL
55 else
56 LE_GREATER;
6057}
6158
6259// TODO https://github.com/ziglang/zig/issues/305
......@@ -76,21 +73,17 @@ pub extern fn __getf2(a: f128, b: f128) c_int {
7673
7774 if (aAbs > infRep or bAbs > infRep) return GE_UNORDERED;
7875 if ((aAbs | bAbs) == 0) return GE_EQUAL;
79 return if ((aInt & bInt) >= 0)
80 if (aInt < bInt)
81 GE_LESS
82 else if (aInt == bInt)
83 GE_EQUAL
84 else
85 GE_GREATER
76 return if ((aInt & bInt) >= 0) if (aInt < bInt)
77 GE_LESS
78 else if (aInt == bInt)
79 GE_EQUAL
80 else
81 GE_GREATER else if (aInt > bInt)
82 GE_LESS
83 else if (aInt == bInt)
84 GE_EQUAL
8685 else
87 if (aInt > bInt)
88 GE_LESS
89 else if (aInt == bInt)
90 GE_EQUAL
91 else
92 GE_GREATER
93 ;
86 GE_GREATER;
9487}
9588
9689pub extern fn __unordtf2(a: f128, b: f128) c_int {
std/special/compiler_rt/fixunsdfti_test.zig-1
......@@ -44,4 +44,3 @@ test "fixunsdfti" {
4444 test__fixunsdfti(-0x1.FFFFFFFFFFFFFp+62, 0);
4545 test__fixunsdfti(-0x1.FFFFFFFFFFFFEp+62, 0);
4646}
47
std/special/compiler_rt/index.zig+9-5
......@@ -92,10 +92,10 @@ pub fn setXmm0(comptime T: type, value: T) void {
9292 const aligned_value: T align(16) = value;
9393 asm volatile (
9494 \\movaps (%[ptr]), %%xmm0
95
96 :
95 :
9796 : [ptr] "r" (&aligned_value)
98 : "xmm0");
97 : "xmm0"
98 );
9999}
100100
101101extern fn __udivdi3(a: u64, b: u64) u64 {
......@@ -159,7 +159,8 @@ fn isArmArch() bool {
159159 builtin.Arch.armebv6t2,
160160 builtin.Arch.armebv5,
161161 builtin.Arch.armebv5te,
162 builtin.Arch.armebv4t => true,
162 builtin.Arch.armebv4t,
163 => true,
163164 else => false,
164165 };
165166}
......@@ -174,7 +175,10 @@ nakedcc fn __aeabi_uidivmod() void {
174175 \\ ldr r1, [sp]
175176 \\ add sp, sp, #4
176177 \\ pop { pc }
177 ::: "r2", "r1");
178 :
179 :
180 : "r2", "r1"
181 );
178182}
179183
180184// _chkstk (_alloca) routine - probe stack between %esp and (%esp-%eax) in 4k increments,
std/unicode.zig+13-9
......@@ -58,6 +58,7 @@ pub fn utf8Encode(c: u32, out: []u8) !u3 {
5858}
5959
6060const Utf8DecodeError = Utf8Decode2Error || Utf8Decode3Error || Utf8Decode4Error;
61
6162/// Decodes the UTF-8 codepoint encoded in the given slice of bytes.
6263/// bytes.len must be equal to utf8ByteSequenceLength(bytes[0]) catch unreachable.
6364/// If you already know the length at comptime, you can call one of
......@@ -150,7 +151,9 @@ pub fn utf8ValidateSlice(s: []const u8) bool {
150151 return false;
151152 }
152153
153 if (utf8Decode(s[i..i+cp_len])) |_| {} else |_| { return false; }
154 if (utf8Decode(s[i..i + cp_len])) |_| {} else |_| {
155 return false;
156 }
154157 i += cp_len;
155158 } else |err| {
156159 return false;
......@@ -179,9 +182,7 @@ pub const Utf8View = struct {
179182 }
180183
181184 pub fn initUnchecked(s: []const u8) Utf8View {
182 return Utf8View {
183 .bytes = s,
184 };
185 return Utf8View{ .bytes = s };
185186 }
186187
187188 pub fn initComptime(comptime s: []const u8) Utf8View {
......@@ -191,12 +192,12 @@ pub const Utf8View = struct {
191192 error.InvalidUtf8 => {
192193 @compileError("invalid utf8");
193194 unreachable;
194 }
195 },
195196 }
196197 }
197198
198199 pub fn iterator(s: &const Utf8View) Utf8Iterator {
199 return Utf8Iterator {
200 return Utf8Iterator{
200201 .bytes = s.bytes,
201202 .i = 0,
202203 };
......@@ -215,7 +216,7 @@ const Utf8Iterator = struct {
215216 const cp_len = utf8ByteSequenceLength(it.bytes[it.i]) catch unreachable;
216217
217218 it.i += cp_len;
218 return it.bytes[it.i-cp_len..it.i];
219 return it.bytes[it.i - cp_len..it.i];
219220 }
220221
221222 pub fn nextCodepoint(it: &Utf8Iterator) ?u32 {
......@@ -304,9 +305,12 @@ test "utf8 view bad" {
304305fn testUtf8ViewBad() void {
305306 // Compile-time error.
306307 // const s3 = Utf8View.initComptime("\xfe\xf2");
307
308308 const s = Utf8View.init("hel\xadlo");
309 if (s) |_| { unreachable; } else |err| { debug.assert(err == error.InvalidUtf8); }
309 if (s) |_| {
310 unreachable;
311 } else |err| {
312 debug.assert(err == error.InvalidUtf8);
313 }
310314}
311315
312316test "utf8 view ok" {
std/zig/ast.zig+5-4
......@@ -388,7 +388,8 @@ pub const Node = struct {
388388 Id.SwitchElse,
389389 Id.FieldInitializer,
390390 Id.DocComment,
391 Id.TestDecl => return false,
391 Id.TestDecl,
392 => return false,
392393 Id.While => {
393394 const while_node = @fieldParentPtr(While, "base", n);
394395 if (while_node.@"else") |@"else"| {
......@@ -608,8 +609,7 @@ pub const Node = struct {
608609 if (i < 1) return t;
609610 i -= 1;
610611 },
611 InitArg.None,
612 InitArg.Enum => {},
612 InitArg.None, InitArg.Enum => {},
613613 }
614614
615615 if (i < self.fields_and_decls.len) return self.fields_and_decls.at(i).*;
......@@ -1475,7 +1475,8 @@ pub const Node = struct {
14751475 Op.Range,
14761476 Op.Sub,
14771477 Op.SubWrap,
1478 Op.UnwrapMaybe => {},
1478 Op.UnwrapMaybe,
1479 => {},
14791480 }
14801481
14811482 if (i < 1) return self.rhs;
std/zig/parse.zig+526-401
......@@ -81,10 +81,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
8181 });
8282 try root_node.decls.push(&test_node.base);
8383 try stack.append(State{ .Block = block });
84 try stack.append(State{ .ExpectTokenSave = ExpectTokenSave{
85 .id = Token.Id.LBrace,
86 .ptr = &block.lbrace,
87 } });
84 try stack.append(State{
85 .ExpectTokenSave = ExpectTokenSave{
86 .id = Token.Id.LBrace,
87 .ptr = &block.lbrace,
88 },
89 });
8890 try stack.append(State{ .StringLiteral = OptionalCtx{ .Required = &test_node.name } });
8991 continue;
9092 },
......@@ -95,13 +97,15 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
9597 },
9698 Token.Id.Keyword_pub => {
9799 stack.append(State.TopLevel) catch unreachable;
98 try stack.append(State{ .TopLevelExtern = TopLevelDeclCtx{
99 .decls = &root_node.decls,
100 .visib_token = token_index,
101 .extern_export_inline_token = null,
102 .lib_name = null,
103 .comments = comments,
104 } });
100 try stack.append(State{
101 .TopLevelExtern = TopLevelDeclCtx{
102 .decls = &root_node.decls,
103 .visib_token = token_index,
104 .extern_export_inline_token = null,
105 .lib_name = null,
106 .comments = comments,
107 },
108 });
105109 continue;
106110 },
107111 Token.Id.Keyword_comptime => {
......@@ -122,22 +126,26 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
122126
123127 stack.append(State.TopLevel) catch unreachable;
124128 try stack.append(State{ .Block = block });
125 try stack.append(State{ .ExpectTokenSave = ExpectTokenSave{
126 .id = Token.Id.LBrace,
127 .ptr = &block.lbrace,
128 } });
129 try stack.append(State{
130 .ExpectTokenSave = ExpectTokenSave{
131 .id = Token.Id.LBrace,
132 .ptr = &block.lbrace,
133 },
134 });
129135 continue;
130136 },
131137 else => {
132138 prevToken(&tok_it, &tree);
133139 stack.append(State.TopLevel) catch unreachable;
134 try stack.append(State{ .TopLevelExtern = TopLevelDeclCtx{
135 .decls = &root_node.decls,
136 .visib_token = null,
137 .extern_export_inline_token = null,
138 .lib_name = null,
139 .comments = comments,
140 } });
140 try stack.append(State{
141 .TopLevelExtern = TopLevelDeclCtx{
142 .decls = &root_node.decls,
143 .visib_token = null,
144 .extern_export_inline_token = null,
145 .lib_name = null,
146 .comments = comments,
147 },
148 });
141149 continue;
142150 },
143151 }
......@@ -147,31 +155,34 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
147155 const token_index = token.index;
148156 const token_ptr = token.ptr;
149157 switch (token_ptr.id) {
150 Token.Id.Keyword_export,
151 Token.Id.Keyword_inline => {
152 stack.append(State{ .TopLevelDecl = TopLevelDeclCtx{
153 .decls = ctx.decls,
154 .visib_token = ctx.visib_token,
155 .extern_export_inline_token = AnnotatedToken{
156 .index = token_index,
157 .ptr = token_ptr,
158 Token.Id.Keyword_export, Token.Id.Keyword_inline => {
159 stack.append(State{
160 .TopLevelDecl = TopLevelDeclCtx{
161 .decls = ctx.decls,
162 .visib_token = ctx.visib_token,
163 .extern_export_inline_token = AnnotatedToken{
164 .index = token_index,
165 .ptr = token_ptr,
166 },
167 .lib_name = null,
168 .comments = ctx.comments,
158169 },
159 .lib_name = null,
160 .comments = ctx.comments,
161 } }) catch unreachable;
170 }) catch unreachable;
162171 continue;
163172 },
164173 Token.Id.Keyword_extern => {
165 stack.append(State{ .TopLevelLibname = TopLevelDeclCtx{
166 .decls = ctx.decls,
167 .visib_token = ctx.visib_token,
168 .extern_export_inline_token = AnnotatedToken{
169 .index = token_index,
170 .ptr = token_ptr,
174 stack.append(State{
175 .TopLevelLibname = TopLevelDeclCtx{
176 .decls = ctx.decls,
177 .visib_token = ctx.visib_token,
178 .extern_export_inline_token = AnnotatedToken{
179 .index = token_index,
180 .ptr = token_ptr,
181 },
182 .lib_name = null,
183 .comments = ctx.comments,
171184 },
172 .lib_name = null,
173 .comments = ctx.comments,
174 } }) catch unreachable;
185 }) catch unreachable;
175186 continue;
176187 },
177188 else => {
......@@ -192,13 +203,15 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
192203 };
193204 };
194205
195 stack.append(State{ .TopLevelDecl = TopLevelDeclCtx{
196 .decls = ctx.decls,
197 .visib_token = ctx.visib_token,
198 .extern_export_inline_token = ctx.extern_export_inline_token,
199 .lib_name = lib_name,
200 .comments = ctx.comments,
201 } }) catch unreachable;
206 stack.append(State{
207 .TopLevelDecl = TopLevelDeclCtx{
208 .decls = ctx.decls,
209 .visib_token = ctx.visib_token,
210 .extern_export_inline_token = ctx.extern_export_inline_token,
211 .lib_name = lib_name,
212 .comments = ctx.comments,
213 },
214 }) catch unreachable;
202215 continue;
203216 },
204217 State.TopLevelDecl => |ctx| {
......@@ -222,15 +235,16 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
222235 });
223236 try ctx.decls.push(&node.base);
224237
225 stack.append(State{ .ExpectTokenSave = ExpectTokenSave{
226 .id = Token.Id.Semicolon,
227 .ptr = &node.semicolon_token,
228 } }) catch unreachable;
238 stack.append(State{
239 .ExpectTokenSave = ExpectTokenSave{
240 .id = Token.Id.Semicolon,
241 .ptr = &node.semicolon_token,
242 },
243 }) catch unreachable;
229244 try stack.append(State{ .Expression = OptionalCtx{ .Required = &node.expr } });
230245 continue;
231246 },
232 Token.Id.Keyword_var,
233 Token.Id.Keyword_const => {
247 Token.Id.Keyword_var, Token.Id.Keyword_const => {
234248 if (ctx.extern_export_inline_token) |annotated_token| {
235249 if (annotated_token.ptr.id == Token.Id.Keyword_inline) {
236250 ((try tree.errors.addOne())).* = Error{ .InvalidToken = Error.InvalidToken{ .token = annotated_token.index } };
......@@ -238,21 +252,20 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
238252 }
239253 }
240254
241 try stack.append(State{ .VarDecl = VarDeclCtx{
242 .comments = ctx.comments,
243 .visib_token = ctx.visib_token,
244 .lib_name = ctx.lib_name,
245 .comptime_token = null,
246 .extern_export_token = if (ctx.extern_export_inline_token) |at| at.index else null,
247 .mut_token = token_index,
248 .list = ctx.decls,
249 } });
255 try stack.append(State{
256 .VarDecl = VarDeclCtx{
257 .comments = ctx.comments,
258 .visib_token = ctx.visib_token,
259 .lib_name = ctx.lib_name,
260 .comptime_token = null,
261 .extern_export_token = if (ctx.extern_export_inline_token) |at| at.index else null,
262 .mut_token = token_index,
263 .list = ctx.decls,
264 },
265 });
250266 continue;
251267 },
252 Token.Id.Keyword_fn,
253 Token.Id.Keyword_nakedcc,
254 Token.Id.Keyword_stdcallcc,
255 Token.Id.Keyword_async => {
268 Token.Id.Keyword_fn, Token.Id.Keyword_nakedcc, Token.Id.Keyword_stdcallcc, Token.Id.Keyword_async => {
256269 const fn_proto = try arena.construct(ast.Node.FnProto{
257270 .base = ast.Node{ .id = ast.Node.Id.FnProto },
258271 .doc_comments = ctx.comments,
......@@ -274,13 +287,14 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
274287 try stack.append(State{ .FnProto = fn_proto });
275288
276289 switch (token_ptr.id) {
277 Token.Id.Keyword_nakedcc,
278 Token.Id.Keyword_stdcallcc => {
290 Token.Id.Keyword_nakedcc, Token.Id.Keyword_stdcallcc => {
279291 fn_proto.cc_token = token_index;
280 try stack.append(State{ .ExpectTokenSave = ExpectTokenSave{
281 .id = Token.Id.Keyword_fn,
282 .ptr = &fn_proto.fn_token,
283 } });
292 try stack.append(State{
293 .ExpectTokenSave = ExpectTokenSave{
294 .id = Token.Id.Keyword_fn,
295 .ptr = &fn_proto.fn_token,
296 },
297 });
284298 continue;
285299 },
286300 Token.Id.Keyword_async => {
......@@ -292,10 +306,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
292306 });
293307 fn_proto.async_attr = async_node;
294308
295 try stack.append(State{ .ExpectTokenSave = ExpectTokenSave{
296 .id = Token.Id.Keyword_fn,
297 .ptr = &fn_proto.fn_token,
298 } });
309 try stack.append(State{
310 .ExpectTokenSave = ExpectTokenSave{
311 .id = Token.Id.Keyword_fn,
312 .ptr = &fn_proto.fn_token,
313 },
314 });
299315 try stack.append(State{ .AsyncAllocator = async_node });
300316 continue;
301317 },
......@@ -331,13 +347,15 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
331347 }
332348
333349 stack.append(State{ .ContainerDecl = ctx.container_decl }) catch unreachable;
334 try stack.append(State{ .TopLevelExtern = TopLevelDeclCtx{
335 .decls = &ctx.container_decl.fields_and_decls,
336 .visib_token = ctx.visib_token,
337 .extern_export_inline_token = null,
338 .lib_name = null,
339 .comments = ctx.comments,
340 } });
350 try stack.append(State{
351 .TopLevelExtern = TopLevelDeclCtx{
352 .decls = &ctx.container_decl.fields_and_decls,
353 .visib_token = ctx.visib_token,
354 .extern_export_inline_token = null,
355 .lib_name = null,
356 .comments = ctx.comments,
357 },
358 });
341359 continue;
342360 },
343361
......@@ -361,9 +379,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
361379 .base = ast.Node{ .id = ast.Node.Id.ContainerDecl },
362380 .layout_token = ctx.layout_token,
363381 .kind_token = switch (token_ptr.id) {
364 Token.Id.Keyword_struct,
365 Token.Id.Keyword_union,
366 Token.Id.Keyword_enum => token_index,
382 Token.Id.Keyword_struct, Token.Id.Keyword_union, Token.Id.Keyword_enum => token_index,
367383 else => {
368384 ((try tree.errors.addOne())).* = Error{ .ExpectedAggregateKw = Error.ExpectedAggregateKw{ .token = token_index } };
369385 return tree;
......@@ -377,10 +393,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
377393 ctx.opt_ctx.store(&node.base);
378394
379395 stack.append(State{ .ContainerDecl = node }) catch unreachable;
380 try stack.append(State{ .ExpectTokenSave = ExpectTokenSave{
381 .id = Token.Id.LBrace,
382 .ptr = &node.lbrace_token,
383 } });
396 try stack.append(State{
397 .ExpectTokenSave = ExpectTokenSave{
398 .id = Token.Id.LBrace,
399 .ptr = &node.lbrace_token,
400 },
401 });
384402 try stack.append(State{ .ContainerInitArgStart = node });
385403 continue;
386404 },
......@@ -481,35 +499,41 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
481499 Token.Id.Keyword_pub => {
482500 switch (tree.tokens.at(container_decl.kind_token).id) {
483501 Token.Id.Keyword_struct => {
484 try stack.append(State{ .TopLevelExternOrField = TopLevelExternOrFieldCtx{
485 .visib_token = token_index,
486 .container_decl = container_decl,
487 .comments = comments,
488 } });
502 try stack.append(State{
503 .TopLevelExternOrField = TopLevelExternOrFieldCtx{
504 .visib_token = token_index,
505 .container_decl = container_decl,
506 .comments = comments,
507 },
508 });
489509 continue;
490510 },
491511 else => {
492512 stack.append(State{ .ContainerDecl = container_decl }) catch unreachable;
493 try stack.append(State{ .TopLevelExtern = TopLevelDeclCtx{
494 .decls = &container_decl.fields_and_decls,
495 .visib_token = token_index,
496 .extern_export_inline_token = null,
497 .lib_name = null,
498 .comments = comments,
499 } });
513 try stack.append(State{
514 .TopLevelExtern = TopLevelDeclCtx{
515 .decls = &container_decl.fields_and_decls,
516 .visib_token = token_index,
517 .extern_export_inline_token = null,
518 .lib_name = null,
519 .comments = comments,
520 },
521 });
500522 continue;
501523 },
502524 }
503525 },
504526 Token.Id.Keyword_export => {
505527 stack.append(State{ .ContainerDecl = container_decl }) catch unreachable;
506 try stack.append(State{ .TopLevelExtern = TopLevelDeclCtx{
507 .decls = &container_decl.fields_and_decls,
508 .visib_token = token_index,
509 .extern_export_inline_token = null,
510 .lib_name = null,
511 .comments = comments,
512 } });
528 try stack.append(State{
529 .TopLevelExtern = TopLevelDeclCtx{
530 .decls = &container_decl.fields_and_decls,
531 .visib_token = token_index,
532 .extern_export_inline_token = null,
533 .lib_name = null,
534 .comments = comments,
535 },
536 });
513537 continue;
514538 },
515539 Token.Id.RBrace => {
......@@ -523,13 +547,15 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
523547 else => {
524548 prevToken(&tok_it, &tree);
525549 stack.append(State{ .ContainerDecl = container_decl }) catch unreachable;
526 try stack.append(State{ .TopLevelExtern = TopLevelDeclCtx{
527 .decls = &container_decl.fields_and_decls,
528 .visib_token = null,
529 .extern_export_inline_token = null,
530 .lib_name = null,
531 .comments = comments,
532 } });
550 try stack.append(State{
551 .TopLevelExtern = TopLevelDeclCtx{
552 .decls = &container_decl.fields_and_decls,
553 .visib_token = null,
554 .extern_export_inline_token = null,
555 .lib_name = null,
556 .comments = comments,
557 },
558 });
533559 continue;
534560 },
535561 }
......@@ -557,10 +583,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
557583 try stack.append(State{ .VarDeclAlign = var_decl });
558584 try stack.append(State{ .TypeExprBegin = OptionalCtx{ .RequiredNull = &var_decl.type_node } });
559585 try stack.append(State{ .IfToken = Token.Id.Colon });
560 try stack.append(State{ .ExpectTokenSave = ExpectTokenSave{
561 .id = Token.Id.Identifier,
562 .ptr = &var_decl.name_token,
563 } });
586 try stack.append(State{
587 .ExpectTokenSave = ExpectTokenSave{
588 .id = Token.Id.Identifier,
589 .ptr = &var_decl.name_token,
590 },
591 });
564592 continue;
565593 },
566594 State.VarDeclAlign => |var_decl| {
......@@ -605,10 +633,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
605633 const semicolon_token = nextToken(&tok_it, &tree);
606634
607635 if (semicolon_token.ptr.id != Token.Id.Semicolon) {
608 ((try tree.errors.addOne())).* = Error{ .ExpectedToken = Error.ExpectedToken{
609 .token = semicolon_token.index,
610 .expected_id = Token.Id.Semicolon,
611 } };
636 ((try tree.errors.addOne())).* = Error{
637 .ExpectedToken = Error.ExpectedToken{
638 .token = semicolon_token.index,
639 .expected_id = Token.Id.Semicolon,
640 },
641 };
612642 return tree;
613643 }
614644
......@@ -713,10 +743,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
713743 });
714744 try fn_proto.params.push(&param_decl.base);
715745
716 stack.append(State{ .ParamDeclEnd = ParamDeclEndCtx{
717 .param_decl = param_decl,
718 .fn_proto = fn_proto,
719 } }) catch unreachable;
746 stack.append(State{
747 .ParamDeclEnd = ParamDeclEndCtx{
748 .param_decl = param_decl,
749 .fn_proto = fn_proto,
750 },
751 }) catch unreachable;
720752 try stack.append(State{ .ParamDeclName = param_decl });
721753 try stack.append(State{ .ParamDeclAliasOrComptime = param_decl });
722754 continue;
......@@ -769,10 +801,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
769801
770802 State.MaybeLabeledExpression => |ctx| {
771803 if (eatToken(&tok_it, &tree, Token.Id.Colon)) |_| {
772 stack.append(State{ .LabeledExpression = LabelCtx{
773 .label = ctx.label,
774 .opt_ctx = ctx.opt_ctx,
775 } }) catch unreachable;
804 stack.append(State{
805 .LabeledExpression = LabelCtx{
806 .label = ctx.label,
807 .opt_ctx = ctx.opt_ctx,
808 },
809 }) catch unreachable;
776810 continue;
777811 }
778812
......@@ -797,21 +831,25 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
797831 continue;
798832 },
799833 Token.Id.Keyword_while => {
800 stack.append(State{ .While = LoopCtx{
801 .label = ctx.label,
802 .inline_token = null,
803 .loop_token = token_index,
804 .opt_ctx = ctx.opt_ctx.toRequired(),
805 } }) catch unreachable;
834 stack.append(State{
835 .While = LoopCtx{
836 .label = ctx.label,
837 .inline_token = null,
838 .loop_token = token_index,
839 .opt_ctx = ctx.opt_ctx.toRequired(),
840 },
841 }) catch unreachable;
806842 continue;
807843 },
808844 Token.Id.Keyword_for => {
809 stack.append(State{ .For = LoopCtx{
810 .label = ctx.label,
811 .inline_token = null,
812 .loop_token = token_index,
813 .opt_ctx = ctx.opt_ctx.toRequired(),
814 } }) catch unreachable;
845 stack.append(State{
846 .For = LoopCtx{
847 .label = ctx.label,
848 .inline_token = null,
849 .loop_token = token_index,
850 .opt_ctx = ctx.opt_ctx.toRequired(),
851 },
852 }) catch unreachable;
815853 continue;
816854 },
817855 Token.Id.Keyword_suspend => {
......@@ -828,11 +866,13 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
828866 continue;
829867 },
830868 Token.Id.Keyword_inline => {
831 stack.append(State{ .Inline = InlineCtx{
832 .label = ctx.label,
833 .inline_token = token_index,
834 .opt_ctx = ctx.opt_ctx.toRequired(),
835 } }) catch unreachable;
869 stack.append(State{
870 .Inline = InlineCtx{
871 .label = ctx.label,
872 .inline_token = token_index,
873 .opt_ctx = ctx.opt_ctx.toRequired(),
874 },
875 }) catch unreachable;
836876 continue;
837877 },
838878 else => {
......@@ -852,21 +892,25 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
852892 const token_ptr = token.ptr;
853893 switch (token_ptr.id) {
854894 Token.Id.Keyword_while => {
855 stack.append(State{ .While = LoopCtx{
856 .inline_token = ctx.inline_token,
857 .label = ctx.label,
858 .loop_token = token_index,
859 .opt_ctx = ctx.opt_ctx.toRequired(),
860 } }) catch unreachable;
895 stack.append(State{
896 .While = LoopCtx{
897 .inline_token = ctx.inline_token,
898 .label = ctx.label,
899 .loop_token = token_index,
900 .opt_ctx = ctx.opt_ctx.toRequired(),
901 },
902 }) catch unreachable;
861903 continue;
862904 },
863905 Token.Id.Keyword_for => {
864 stack.append(State{ .For = LoopCtx{
865 .inline_token = ctx.inline_token,
866 .label = ctx.label,
867 .loop_token = token_index,
868 .opt_ctx = ctx.opt_ctx.toRequired(),
869 } }) catch unreachable;
906 stack.append(State{
907 .For = LoopCtx{
908 .inline_token = ctx.inline_token,
909 .label = ctx.label,
910 .loop_token = token_index,
911 .opt_ctx = ctx.opt_ctx.toRequired(),
912 },
913 }) catch unreachable;
870914 continue;
871915 },
872916 else => {
......@@ -971,27 +1015,29 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
9711015 const token_ptr = token.ptr;
9721016 switch (token_ptr.id) {
9731017 Token.Id.Keyword_comptime => {
974 stack.append(State{ .ComptimeStatement = ComptimeStatementCtx{
975 .comptime_token = token_index,
976 .block = block,
977 } }) catch unreachable;
978 continue;
979 },
980 Token.Id.Keyword_var,
981 Token.Id.Keyword_const => {
982 stack.append(State{ .VarDecl = VarDeclCtx{
983 .comments = null,
984 .visib_token = null,
985 .comptime_token = null,
986 .extern_export_token = null,
987 .lib_name = null,
988 .mut_token = token_index,
989 .list = &block.statements,
990 } }) catch unreachable;
1018 stack.append(State{
1019 .ComptimeStatement = ComptimeStatementCtx{
1020 .comptime_token = token_index,
1021 .block = block,
1022 },
1023 }) catch unreachable;
1024 continue;
1025 },
1026 Token.Id.Keyword_var, Token.Id.Keyword_const => {
1027 stack.append(State{
1028 .VarDecl = VarDeclCtx{
1029 .comments = null,
1030 .visib_token = null,
1031 .comptime_token = null,
1032 .extern_export_token = null,
1033 .lib_name = null,
1034 .mut_token = token_index,
1035 .list = &block.statements,
1036 },
1037 }) catch unreachable;
9911038 continue;
9921039 },
993 Token.Id.Keyword_defer,
994 Token.Id.Keyword_errdefer => {
1040 Token.Id.Keyword_defer, Token.Id.Keyword_errdefer => {
9951041 const node = try arena.construct(ast.Node.Defer{
9961042 .base = ast.Node{ .id = ast.Node.Id.Defer },
9971043 .defer_token = token_index,
......@@ -1036,17 +1082,18 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
10361082 const token_index = token.index;
10371083 const token_ptr = token.ptr;
10381084 switch (token_ptr.id) {
1039 Token.Id.Keyword_var,
1040 Token.Id.Keyword_const => {
1041 stack.append(State{ .VarDecl = VarDeclCtx{
1042 .comments = null,
1043 .visib_token = null,
1044 .comptime_token = ctx.comptime_token,
1045 .extern_export_token = null,
1046 .lib_name = null,
1047 .mut_token = token_index,
1048 .list = &ctx.block.statements,
1049 } }) catch unreachable;
1085 Token.Id.Keyword_var, Token.Id.Keyword_const => {
1086 stack.append(State{
1087 .VarDecl = VarDeclCtx{
1088 .comments = null,
1089 .visib_token = null,
1090 .comptime_token = ctx.comptime_token,
1091 .extern_export_token = null,
1092 .lib_name = null,
1093 .mut_token = token_index,
1094 .list = &ctx.block.statements,
1095 },
1096 }) catch unreachable;
10501097 continue;
10511098 },
10521099 else => {
......@@ -1089,10 +1136,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
10891136
10901137 stack.append(State{ .AsmOutputItems = items }) catch unreachable;
10911138 try stack.append(State{ .IfToken = Token.Id.Comma });
1092 try stack.append(State{ .ExpectTokenSave = ExpectTokenSave{
1093 .id = Token.Id.RParen,
1094 .ptr = &node.rparen,
1095 } });
1139 try stack.append(State{
1140 .ExpectTokenSave = ExpectTokenSave{
1141 .id = Token.Id.RParen,
1142 .ptr = &node.rparen,
1143 },
1144 });
10961145 try stack.append(State{ .AsmOutputReturnOrType = node });
10971146 try stack.append(State{ .ExpectToken = Token.Id.LParen });
10981147 try stack.append(State{ .StringLiteral = OptionalCtx{ .Required = &node.constraint } });
......@@ -1141,10 +1190,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
11411190
11421191 stack.append(State{ .AsmInputItems = items }) catch unreachable;
11431192 try stack.append(State{ .IfToken = Token.Id.Comma });
1144 try stack.append(State{ .ExpectTokenSave = ExpectTokenSave{
1145 .id = Token.Id.RParen,
1146 .ptr = &node.rparen,
1147 } });
1193 try stack.append(State{
1194 .ExpectTokenSave = ExpectTokenSave{
1195 .id = Token.Id.RParen,
1196 .ptr = &node.rparen,
1197 },
1198 });
11481199 try stack.append(State{ .Expression = OptionalCtx{ .Required = &node.expr } });
11491200 try stack.append(State{ .ExpectToken = Token.Id.LParen });
11501201 try stack.append(State{ .StringLiteral = OptionalCtx{ .Required = &node.constraint } });
......@@ -1203,14 +1254,18 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
12031254 stack.append(State{ .FieldInitListCommaOrEnd = list_state }) catch unreachable;
12041255 try stack.append(State{ .Expression = OptionalCtx{ .Required = &node.expr } });
12051256 try stack.append(State{ .ExpectToken = Token.Id.Equal });
1206 try stack.append(State{ .ExpectTokenSave = ExpectTokenSave{
1207 .id = Token.Id.Identifier,
1208 .ptr = &node.name_token,
1209 } });
1210 try stack.append(State{ .ExpectTokenSave = ExpectTokenSave{
1211 .id = Token.Id.Period,
1212 .ptr = &node.period_token,
1213 } });
1257 try stack.append(State{
1258 .ExpectTokenSave = ExpectTokenSave{
1259 .id = Token.Id.Identifier,
1260 .ptr = &node.name_token,
1261 },
1262 });
1263 try stack.append(State{
1264 .ExpectTokenSave = ExpectTokenSave{
1265 .id = Token.Id.Period,
1266 .ptr = &node.period_token,
1267 },
1268 });
12141269 continue;
12151270 },
12161271 State.FieldInitListCommaOrEnd => |list_state| {
......@@ -1320,10 +1375,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
13201375 });
13211376 try switch_case.items.push(&else_node.base);
13221377
1323 try stack.append(State{ .ExpectTokenSave = ExpectTokenSave{
1324 .id = Token.Id.EqualAngleBracketRight,
1325 .ptr = &switch_case.arrow_token,
1326 } });
1378 try stack.append(State{
1379 .ExpectTokenSave = ExpectTokenSave{
1380 .id = Token.Id.EqualAngleBracketRight,
1381 .ptr = &switch_case.arrow_token,
1382 },
1383 });
13271384 continue;
13281385 } else {
13291386 prevToken(&tok_it, &tree);
......@@ -1374,10 +1431,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
13741431 }
13751432
13761433 async_node.rangle_bracket = TokenIndex(0);
1377 try stack.append(State{ .ExpectTokenSave = ExpectTokenSave{
1378 .id = Token.Id.AngleBracketRight,
1379 .ptr = &??async_node.rangle_bracket,
1380 } });
1434 try stack.append(State{
1435 .ExpectTokenSave = ExpectTokenSave{
1436 .id = Token.Id.AngleBracketRight,
1437 .ptr = &??async_node.rangle_bracket,
1438 },
1439 });
13811440 try stack.append(State{ .TypeExprBegin = OptionalCtx{ .RequiredNull = &async_node.allocator_type } });
13821441 continue;
13831442 },
......@@ -1430,10 +1489,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
14301489 continue;
14311490 }
14321491
1433 stack.append(State{ .ContainerKind = ContainerKindCtx{
1434 .opt_ctx = ctx.opt_ctx,
1435 .layout_token = ctx.extern_token,
1436 } }) catch unreachable;
1492 stack.append(State{
1493 .ContainerKind = ContainerKindCtx{
1494 .opt_ctx = ctx.opt_ctx,
1495 .layout_token = ctx.extern_token,
1496 },
1497 }) catch unreachable;
14371498 continue;
14381499 },
14391500 State.SliceOrArrayAccess => |node| {
......@@ -1443,15 +1504,19 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
14431504 switch (token_ptr.id) {
14441505 Token.Id.Ellipsis2 => {
14451506 const start = node.op.ArrayAccess;
1446 node.op = ast.Node.SuffixOp.Op{ .Slice = ast.Node.SuffixOp.Op.Slice{
1447 .start = start,
1448 .end = null,
1449 } };
1507 node.op = ast.Node.SuffixOp.Op{
1508 .Slice = ast.Node.SuffixOp.Op.Slice{
1509 .start = start,
1510 .end = null,
1511 },
1512 };
14501513
1451 stack.append(State{ .ExpectTokenSave = ExpectTokenSave{
1452 .id = Token.Id.RBracket,
1453 .ptr = &node.rtoken,
1454 } }) catch unreachable;
1514 stack.append(State{
1515 .ExpectTokenSave = ExpectTokenSave{
1516 .id = Token.Id.RBracket,
1517 .ptr = &node.rtoken,
1518 },
1519 }) catch unreachable;
14551520 try stack.append(State{ .Expression = OptionalCtx{ .Optional = &node.op.Slice.end } });
14561521 continue;
14571522 },
......@@ -1467,11 +1532,13 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
14671532 },
14681533 State.SliceOrArrayType => |node| {
14691534 if (eatToken(&tok_it, &tree, Token.Id.RBracket)) |_| {
1470 node.op = ast.Node.PrefixOp.Op{ .SliceType = ast.Node.PrefixOp.AddrOfInfo{
1471 .align_info = null,
1472 .const_token = null,
1473 .volatile_token = null,
1474 } };
1535 node.op = ast.Node.PrefixOp.Op{
1536 .SliceType = ast.Node.PrefixOp.AddrOfInfo{
1537 .align_info = null,
1538 .const_token = null,
1539 .volatile_token = null,
1540 },
1541 };
14751542 stack.append(State{ .TypeExprBegin = OptionalCtx{ .Required = &node.rhs } }) catch unreachable;
14761543 try stack.append(State{ .AddrOfModifiers = &node.op.SliceType });
14771544 continue;
......@@ -1495,7 +1562,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
14951562 ((try tree.errors.addOne())).* = Error{ .ExtraAlignQualifier = Error.ExtraAlignQualifier{ .token = token_index } };
14961563 return tree;
14971564 }
1498 addr_of_info.align_info = ast.Node.PrefixOp.AddrOfInfo.Align {
1565 addr_of_info.align_info = ast.Node.PrefixOp.AddrOfInfo.Align{
14991566 .node = undefined,
15001567 .bit_range = null,
15011568 };
......@@ -1548,9 +1615,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
15481615 Token.Id.RParen => continue,
15491616 else => {
15501617 (try tree.errors.addOne()).* = Error{
1551 .ExpectedColonOrRParen = Error.ExpectedColonOrRParen{
1552 .token = token.index,
1553 }
1618 .ExpectedColonOrRParen = Error.ExpectedColonOrRParen{ .token = token.index },
15541619 };
15551620 return tree;
15561621 },
......@@ -1563,10 +1628,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
15631628 const token_ptr = token.ptr;
15641629 if (token_ptr.id != Token.Id.Pipe) {
15651630 if (opt_ctx != OptionalCtx.Optional) {
1566 ((try tree.errors.addOne())).* = Error{ .ExpectedToken = Error.ExpectedToken{
1567 .token = token_index,
1568 .expected_id = Token.Id.Pipe,
1569 } };
1631 ((try tree.errors.addOne())).* = Error{
1632 .ExpectedToken = Error.ExpectedToken{
1633 .token = token_index,
1634 .expected_id = Token.Id.Pipe,
1635 },
1636 };
15701637 return tree;
15711638 }
15721639
......@@ -1582,10 +1649,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
15821649 });
15831650 opt_ctx.store(&node.base);
15841651
1585 stack.append(State{ .ExpectTokenSave = ExpectTokenSave{
1586 .id = Token.Id.Pipe,
1587 .ptr = &node.rpipe,
1588 } }) catch unreachable;
1652 stack.append(State{
1653 .ExpectTokenSave = ExpectTokenSave{
1654 .id = Token.Id.Pipe,
1655 .ptr = &node.rpipe,
1656 },
1657 }) catch unreachable;
15891658 try stack.append(State{ .Identifier = OptionalCtx{ .Required = &node.error_symbol } });
15901659 continue;
15911660 },
......@@ -1595,10 +1664,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
15951664 const token_ptr = token.ptr;
15961665 if (token_ptr.id != Token.Id.Pipe) {
15971666 if (opt_ctx != OptionalCtx.Optional) {
1598 ((try tree.errors.addOne())).* = Error{ .ExpectedToken = Error.ExpectedToken{
1599 .token = token_index,
1600 .expected_id = Token.Id.Pipe,
1601 } };
1667 ((try tree.errors.addOne())).* = Error{
1668 .ExpectedToken = Error.ExpectedToken{
1669 .token = token_index,
1670 .expected_id = Token.Id.Pipe,
1671 },
1672 };
16021673 return tree;
16031674 }
16041675
......@@ -1615,15 +1686,19 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
16151686 });
16161687 opt_ctx.store(&node.base);
16171688
1618 try stack.append(State{ .ExpectTokenSave = ExpectTokenSave{
1619 .id = Token.Id.Pipe,
1620 .ptr = &node.rpipe,
1621 } });
1689 try stack.append(State{
1690 .ExpectTokenSave = ExpectTokenSave{
1691 .id = Token.Id.Pipe,
1692 .ptr = &node.rpipe,
1693 },
1694 });
16221695 try stack.append(State{ .Identifier = OptionalCtx{ .Required = &node.value_symbol } });
1623 try stack.append(State{ .OptionalTokenSave = OptionalTokenSave{
1624 .id = Token.Id.Asterisk,
1625 .ptr = &node.ptr_token,
1626 } });
1696 try stack.append(State{
1697 .OptionalTokenSave = OptionalTokenSave{
1698 .id = Token.Id.Asterisk,
1699 .ptr = &node.ptr_token,
1700 },
1701 });
16271702 continue;
16281703 },
16291704 State.PointerIndexPayload => |opt_ctx| {
......@@ -1632,10 +1707,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
16321707 const token_ptr = token.ptr;
16331708 if (token_ptr.id != Token.Id.Pipe) {
16341709 if (opt_ctx != OptionalCtx.Optional) {
1635 ((try tree.errors.addOne())).* = Error{ .ExpectedToken = Error.ExpectedToken{
1636 .token = token_index,
1637 .expected_id = Token.Id.Pipe,
1638 } };
1710 ((try tree.errors.addOne())).* = Error{
1711 .ExpectedToken = Error.ExpectedToken{
1712 .token = token_index,
1713 .expected_id = Token.Id.Pipe,
1714 },
1715 };
16391716 return tree;
16401717 }
16411718
......@@ -1653,17 +1730,21 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
16531730 });
16541731 opt_ctx.store(&node.base);
16551732
1656 stack.append(State{ .ExpectTokenSave = ExpectTokenSave{
1657 .id = Token.Id.Pipe,
1658 .ptr = &node.rpipe,
1659 } }) catch unreachable;
1733 stack.append(State{
1734 .ExpectTokenSave = ExpectTokenSave{
1735 .id = Token.Id.Pipe,
1736 .ptr = &node.rpipe,
1737 },
1738 }) catch unreachable;
16601739 try stack.append(State{ .Identifier = OptionalCtx{ .RequiredNull = &node.index_symbol } });
16611740 try stack.append(State{ .IfToken = Token.Id.Comma });
16621741 try stack.append(State{ .Identifier = OptionalCtx{ .Required = &node.value_symbol } });
1663 try stack.append(State{ .OptionalTokenSave = OptionalTokenSave{
1664 .id = Token.Id.Asterisk,
1665 .ptr = &node.ptr_token,
1666 } });
1742 try stack.append(State{
1743 .OptionalTokenSave = OptionalTokenSave{
1744 .id = Token.Id.Asterisk,
1745 .ptr = &node.ptr_token,
1746 },
1747 });
16671748 continue;
16681749 },
16691750
......@@ -1672,9 +1753,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
16721753 const token_index = token.index;
16731754 const token_ptr = token.ptr;
16741755 switch (token_ptr.id) {
1675 Token.Id.Keyword_return,
1676 Token.Id.Keyword_break,
1677 Token.Id.Keyword_continue => {
1756 Token.Id.Keyword_return, Token.Id.Keyword_break, Token.Id.Keyword_continue => {
16781757 const node = try arena.construct(ast.Node.ControlFlowExpression{
16791758 .base = ast.Node{ .id = ast.Node.Id.ControlFlowExpression },
16801759 .ltoken = token_index,
......@@ -1703,9 +1782,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
17031782 }
17041783 continue;
17051784 },
1706 Token.Id.Keyword_try,
1707 Token.Id.Keyword_cancel,
1708 Token.Id.Keyword_resume => {
1785 Token.Id.Keyword_try, Token.Id.Keyword_cancel, Token.Id.Keyword_resume => {
17091786 const node = try arena.construct(ast.Node.PrefixOp{
17101787 .base = ast.Node{ .id = ast.Node.Id.PrefixOp },
17111788 .op_token = token_index,
......@@ -2078,10 +2155,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
20782155
20792156 stack.append(State{ .CurlySuffixExpressionEnd = opt_ctx.toRequired() }) catch unreachable;
20802157 try stack.append(State{ .IfToken = Token.Id.LBrace });
2081 try stack.append(State{ .FieldInitListItemOrEnd = ListSave(@typeOf(node.op.StructInitializer)){
2082 .list = &node.op.StructInitializer,
2083 .ptr = &node.rtoken,
2084 } });
2158 try stack.append(State{
2159 .FieldInitListItemOrEnd = ListSave(@typeOf(node.op.StructInitializer)){
2160 .list = &node.op.StructInitializer,
2161 .ptr = &node.rtoken,
2162 },
2163 });
20852164 continue;
20862165 }
20872166
......@@ -2094,11 +2173,13 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
20942173 opt_ctx.store(&node.base);
20952174 stack.append(State{ .CurlySuffixExpressionEnd = opt_ctx.toRequired() }) catch unreachable;
20962175 try stack.append(State{ .IfToken = Token.Id.LBrace });
2097 try stack.append(State{ .ExprListItemOrEnd = ExprListCtx{
2098 .list = &node.op.ArrayInitializer,
2099 .end = Token.Id.RBrace,
2100 .ptr = &node.rtoken,
2101 } });
2176 try stack.append(State{
2177 .ExprListItemOrEnd = ExprListCtx{
2178 .list = &node.op.ArrayInitializer,
2179 .end = Token.Id.RBrace,
2180 .ptr = &node.rtoken,
2181 },
2182 });
21022183 continue;
21032184 },
21042185
......@@ -2171,10 +2252,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
21712252 .allocator_type = null,
21722253 .rangle_bracket = null,
21732254 });
2174 stack.append(State{ .AsyncEnd = AsyncEndCtx{
2175 .ctx = opt_ctx,
2176 .attribute = async_node,
2177 } }) catch unreachable;
2255 stack.append(State{
2256 .AsyncEnd = AsyncEndCtx{
2257 .ctx = opt_ctx,
2258 .attribute = async_node,
2259 },
2260 }) catch unreachable;
21782261 try stack.append(State{ .SuffixOpExpressionEnd = opt_ctx.toRequired() });
21792262 try stack.append(State{ .PrimaryExpression = opt_ctx.toRequired() });
21802263 try stack.append(State{ .AsyncAllocator = async_node });
......@@ -2197,20 +2280,24 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
21972280 const node = try arena.construct(ast.Node.SuffixOp{
21982281 .base = ast.Node{ .id = ast.Node.Id.SuffixOp },
21992282 .lhs = lhs,
2200 .op = ast.Node.SuffixOp.Op{ .Call = ast.Node.SuffixOp.Op.Call{
2201 .params = ast.Node.SuffixOp.Op.Call.ParamList.init(arena),
2202 .async_attr = null,
2203 } },
2283 .op = ast.Node.SuffixOp.Op{
2284 .Call = ast.Node.SuffixOp.Op.Call{
2285 .params = ast.Node.SuffixOp.Op.Call.ParamList.init(arena),
2286 .async_attr = null,
2287 },
2288 },
22042289 .rtoken = undefined,
22052290 });
22062291 opt_ctx.store(&node.base);
22072292
22082293 stack.append(State{ .SuffixOpExpressionEnd = opt_ctx.toRequired() }) catch unreachable;
2209 try stack.append(State{ .ExprListItemOrEnd = ExprListCtx{
2210 .list = &node.op.Call.params,
2211 .end = Token.Id.RParen,
2212 .ptr = &node.rtoken,
2213 } });
2294 try stack.append(State{
2295 .ExprListItemOrEnd = ExprListCtx{
2296 .list = &node.op.Call.params,
2297 .end = Token.Id.RParen,
2298 .ptr = &node.rtoken,
2299 },
2300 });
22142301 continue;
22152302 },
22162303 Token.Id.LBracket => {
......@@ -2278,8 +2365,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
22782365 _ = try createToCtxLiteral(arena, opt_ctx, ast.Node.UndefinedLiteral, token.index);
22792366 continue;
22802367 },
2281 Token.Id.Keyword_true,
2282 Token.Id.Keyword_false => {
2368 Token.Id.Keyword_true, Token.Id.Keyword_false => {
22832369 _ = try createToCtxLiteral(arena, opt_ctx, ast.Node.BoolLiteral, token.index);
22842370 continue;
22852371 },
......@@ -2321,8 +2407,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
23212407 try stack.append(State{ .Expression = OptionalCtx{ .Required = return_type_ptr } });
23222408 continue;
23232409 },
2324 Token.Id.StringLiteral,
2325 Token.Id.MultilineStringLiteralLine => {
2410 Token.Id.StringLiteral, Token.Id.MultilineStringLiteralLine => {
23262411 opt_ctx.store((try parseStringLiteral(arena, &tok_it, token.ptr, token.index, &tree)) ?? unreachable);
23272412 continue;
23282413 },
......@@ -2335,10 +2420,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
23352420 });
23362421 opt_ctx.store(&node.base);
23372422
2338 stack.append(State{ .ExpectTokenSave = ExpectTokenSave{
2339 .id = Token.Id.RParen,
2340 .ptr = &node.rparen,
2341 } }) catch unreachable;
2423 stack.append(State{
2424 .ExpectTokenSave = ExpectTokenSave{
2425 .id = Token.Id.RParen,
2426 .ptr = &node.rparen,
2427 },
2428 }) catch unreachable;
23422429 try stack.append(State{ .Expression = OptionalCtx{ .Required = &node.expr } });
23432430 continue;
23442431 },
......@@ -2351,11 +2438,13 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
23512438 });
23522439 opt_ctx.store(&node.base);
23532440
2354 stack.append(State{ .ExprListItemOrEnd = ExprListCtx{
2355 .list = &node.params,
2356 .end = Token.Id.RParen,
2357 .ptr = &node.rparen_token,
2358 } }) catch unreachable;
2441 stack.append(State{
2442 .ExprListItemOrEnd = ExprListCtx{
2443 .list = &node.params,
2444 .end = Token.Id.RParen,
2445 .ptr = &node.rparen_token,
2446 },
2447 }) catch unreachable;
23592448 try stack.append(State{ .ExpectToken = Token.Id.LParen });
23602449 continue;
23612450 },
......@@ -2372,42 +2461,50 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
23722461 continue;
23732462 },
23742463 Token.Id.Keyword_error => {
2375 stack.append(State{ .ErrorTypeOrSetDecl = ErrorTypeOrSetDeclCtx{
2376 .error_token = token.index,
2377 .opt_ctx = opt_ctx,
2378 } }) catch unreachable;
2464 stack.append(State{
2465 .ErrorTypeOrSetDecl = ErrorTypeOrSetDeclCtx{
2466 .error_token = token.index,
2467 .opt_ctx = opt_ctx,
2468 },
2469 }) catch unreachable;
23792470 continue;
23802471 },
23812472 Token.Id.Keyword_packed => {
2382 stack.append(State{ .ContainerKind = ContainerKindCtx{
2383 .opt_ctx = opt_ctx,
2384 .layout_token = token.index,
2385 } }) catch unreachable;
2473 stack.append(State{
2474 .ContainerKind = ContainerKindCtx{
2475 .opt_ctx = opt_ctx,
2476 .layout_token = token.index,
2477 },
2478 }) catch unreachable;
23862479 continue;
23872480 },
23882481 Token.Id.Keyword_extern => {
2389 stack.append(State{ .ExternType = ExternTypeCtx{
2390 .opt_ctx = opt_ctx,
2391 .extern_token = token.index,
2392 .comments = null,
2393 } }) catch unreachable;
2482 stack.append(State{
2483 .ExternType = ExternTypeCtx{
2484 .opt_ctx = opt_ctx,
2485 .extern_token = token.index,
2486 .comments = null,
2487 },
2488 }) catch unreachable;
23942489 continue;
23952490 },
2396 Token.Id.Keyword_struct,
2397 Token.Id.Keyword_union,
2398 Token.Id.Keyword_enum => {
2491 Token.Id.Keyword_struct, Token.Id.Keyword_union, Token.Id.Keyword_enum => {
23992492 prevToken(&tok_it, &tree);
2400 stack.append(State{ .ContainerKind = ContainerKindCtx{
2401 .opt_ctx = opt_ctx,
2402 .layout_token = null,
2403 } }) catch unreachable;
2493 stack.append(State{
2494 .ContainerKind = ContainerKindCtx{
2495 .opt_ctx = opt_ctx,
2496 .layout_token = null,
2497 },
2498 }) catch unreachable;
24042499 continue;
24052500 },
24062501 Token.Id.Identifier => {
2407 stack.append(State{ .MaybeLabeledExpression = MaybeLabeledExpressionCtx{
2408 .label = token.index,
2409 .opt_ctx = opt_ctx,
2410 } }) catch unreachable;
2502 stack.append(State{
2503 .MaybeLabeledExpression = MaybeLabeledExpressionCtx{
2504 .label = token.index,
2505 .opt_ctx = opt_ctx,
2506 },
2507 }) catch unreachable;
24112508 continue;
24122509 },
24132510 Token.Id.Keyword_fn => {
......@@ -2431,8 +2528,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
24312528 stack.append(State{ .FnProto = fn_proto }) catch unreachable;
24322529 continue;
24332530 },
2434 Token.Id.Keyword_nakedcc,
2435 Token.Id.Keyword_stdcallcc => {
2531 Token.Id.Keyword_nakedcc, Token.Id.Keyword_stdcallcc => {
24362532 const fn_proto = try arena.construct(ast.Node.FnProto{
24372533 .base = ast.Node{ .id = ast.Node.Id.FnProto },
24382534 .doc_comments = null,
......@@ -2451,10 +2547,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
24512547 });
24522548 opt_ctx.store(&fn_proto.base);
24532549 stack.append(State{ .FnProto = fn_proto }) catch unreachable;
2454 try stack.append(State{ .ExpectTokenSave = ExpectTokenSave{
2455 .id = Token.Id.Keyword_fn,
2456 .ptr = &fn_proto.fn_token,
2457 } });
2550 try stack.append(State{
2551 .ExpectTokenSave = ExpectTokenSave{
2552 .id = Token.Id.Keyword_fn,
2553 .ptr = &fn_proto.fn_token,
2554 },
2555 });
24582556 continue;
24592557 },
24602558 Token.Id.Keyword_asm => {
......@@ -2470,10 +2568,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
24702568 });
24712569 opt_ctx.store(&node.base);
24722570
2473 stack.append(State{ .ExpectTokenSave = ExpectTokenSave{
2474 .id = Token.Id.RParen,
2475 .ptr = &node.rparen,
2476 } }) catch unreachable;
2571 stack.append(State{
2572 .ExpectTokenSave = ExpectTokenSave{
2573 .id = Token.Id.RParen,
2574 .ptr = &node.rparen,
2575 },
2576 }) catch unreachable;
24772577 try stack.append(State{ .AsmClobberItems = &node.clobbers });
24782578 try stack.append(State{ .IfToken = Token.Id.Colon });
24792579 try stack.append(State{ .AsmInputItems = &node.inputs });
......@@ -2482,17 +2582,21 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
24822582 try stack.append(State{ .IfToken = Token.Id.Colon });
24832583 try stack.append(State{ .StringLiteral = OptionalCtx{ .Required = &node.template } });
24842584 try stack.append(State{ .ExpectToken = Token.Id.LParen });
2485 try stack.append(State{ .OptionalTokenSave = OptionalTokenSave{
2486 .id = Token.Id.Keyword_volatile,
2487 .ptr = &node.volatile_token,
2488 } });
2585 try stack.append(State{
2586 .OptionalTokenSave = OptionalTokenSave{
2587 .id = Token.Id.Keyword_volatile,
2588 .ptr = &node.volatile_token,
2589 },
2590 });
24892591 },
24902592 Token.Id.Keyword_inline => {
2491 stack.append(State{ .Inline = InlineCtx{
2492 .label = null,
2493 .inline_token = token.index,
2494 .opt_ctx = opt_ctx,
2495 } }) catch unreachable;
2593 stack.append(State{
2594 .Inline = InlineCtx{
2595 .label = null,
2596 .inline_token = token.index,
2597 .opt_ctx = opt_ctx,
2598 },
2599 }) catch unreachable;
24962600 continue;
24972601 },
24982602 else => {
......@@ -2522,10 +2626,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
25222626 });
25232627 ctx.opt_ctx.store(&node.base);
25242628
2525 stack.append(State{ .ErrorTagListItemOrEnd = ListSave(@typeOf(node.decls)){
2526 .list = &node.decls,
2527 .ptr = &node.rbrace_token,
2528 } }) catch unreachable;
2629 stack.append(State{
2630 .ErrorTagListItemOrEnd = ListSave(@typeOf(node.decls)){
2631 .list = &node.decls,
2632 .ptr = &node.rbrace_token,
2633 },
2634 }) catch unreachable;
25292635 continue;
25302636 },
25312637 State.StringLiteral => |opt_ctx| {
......@@ -2553,10 +2659,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
25532659 const token = nextToken(&tok_it, &tree);
25542660 const token_index = token.index;
25552661 const token_ptr = token.ptr;
2556 ((try tree.errors.addOne())).* = Error{ .ExpectedToken = Error.ExpectedToken{
2557 .token = token_index,
2558 .expected_id = Token.Id.Identifier,
2559 } };
2662 ((try tree.errors.addOne())).* = Error{
2663 .ExpectedToken = Error.ExpectedToken{
2664 .token = token_index,
2665 .expected_id = Token.Id.Identifier,
2666 },
2667 };
25602668 return tree;
25612669 }
25622670 },
......@@ -2567,10 +2675,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
25672675 const ident_token_index = ident_token.index;
25682676 const ident_token_ptr = ident_token.ptr;
25692677 if (ident_token_ptr.id != Token.Id.Identifier) {
2570 ((try tree.errors.addOne())).* = Error{ .ExpectedToken = Error.ExpectedToken{
2571 .token = ident_token_index,
2572 .expected_id = Token.Id.Identifier,
2573 } };
2678 ((try tree.errors.addOne())).* = Error{
2679 .ExpectedToken = Error.ExpectedToken{
2680 .token = ident_token_index,
2681 .expected_id = Token.Id.Identifier,
2682 },
2683 };
25742684 return tree;
25752685 }
25762686
......@@ -2588,10 +2698,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
25882698 const token_index = token.index;
25892699 const token_ptr = token.ptr;
25902700 if (token_ptr.id != token_id) {
2591 ((try tree.errors.addOne())).* = Error{ .ExpectedToken = Error.ExpectedToken{
2592 .token = token_index,
2593 .expected_id = token_id,
2594 } };
2701 ((try tree.errors.addOne())).* = Error{
2702 .ExpectedToken = Error.ExpectedToken{
2703 .token = token_index,
2704 .expected_id = token_id,
2705 },
2706 };
25952707 return tree;
25962708 }
25972709 continue;
......@@ -2601,10 +2713,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
26012713 const token_index = token.index;
26022714 const token_ptr = token.ptr;
26032715 if (token_ptr.id != expect_token_save.id) {
2604 ((try tree.errors.addOne())).* = Error{ .ExpectedToken = Error.ExpectedToken{
2605 .token = token_index,
2606 .expected_id = expect_token_save.id,
2607 } };
2716 ((try tree.errors.addOne())).* = Error{
2717 .ExpectedToken = Error.ExpectedToken{
2718 .token = token_index,
2719 .expected_id = expect_token_save.id,
2720 },
2721 };
26082722 return tree;
26092723 }
26102724 expect_token_save.ptr.* = token_index;
......@@ -2997,21 +3111,25 @@ fn parseBlockExpr(stack: &std.ArrayList(State), arena: &mem.Allocator, ctx: &con
29973111 return true;
29983112 },
29993113 Token.Id.Keyword_while => {
3000 stack.append(State{ .While = LoopCtx{
3001 .label = null,
3002 .inline_token = null,
3003 .loop_token = token_index,
3004 .opt_ctx = ctx.*,
3005 } }) catch unreachable;
3114 stack.append(State{
3115 .While = LoopCtx{
3116 .label = null,
3117 .inline_token = null,
3118 .loop_token = token_index,
3119 .opt_ctx = ctx.*,
3120 },
3121 }) catch unreachable;
30063122 return true;
30073123 },
30083124 Token.Id.Keyword_for => {
3009 stack.append(State{ .For = LoopCtx{
3010 .label = null,
3011 .inline_token = null,
3012 .loop_token = token_index,
3013 .opt_ctx = ctx.*,
3014 } }) catch unreachable;
3125 stack.append(State{
3126 .For = LoopCtx{
3127 .label = null,
3128 .inline_token = null,
3129 .loop_token = token_index,
3130 .opt_ctx = ctx.*,
3131 },
3132 }) catch unreachable;
30153133 return true;
30163134 },
30173135 Token.Id.Keyword_switch => {
......@@ -3024,10 +3142,12 @@ fn parseBlockExpr(stack: &std.ArrayList(State), arena: &mem.Allocator, ctx: &con
30243142 });
30253143 ctx.store(&node.base);
30263144
3027 stack.append(State{ .SwitchCaseOrEnd = ListSave(@typeOf(node.cases)){
3028 .list = &node.cases,
3029 .ptr = &node.rbrace,
3030 } }) catch unreachable;
3145 stack.append(State{
3146 .SwitchCaseOrEnd = ListSave(@typeOf(node.cases)){
3147 .list = &node.cases,
3148 .ptr = &node.rbrace,
3149 },
3150 }) catch unreachable;
30313151 try stack.append(State{ .ExpectToken = Token.Id.LBrace });
30323152 try stack.append(State{ .ExpectToken = Token.Id.RParen });
30333153 try stack.append(State{ .Expression = OptionalCtx{ .Required = &node.expr } });
......@@ -3080,10 +3200,14 @@ fn expectCommaOrEnd(tok_it: &ast.Tree.TokenList.Iterator, tree: &ast.Tree, end:
30803200 return ExpectCommaOrEndResult{ .end_token = token_index };
30813201 }
30823202
3083 return ExpectCommaOrEndResult{ .parse_error = Error{ .ExpectedCommaOrEnd = Error.ExpectedCommaOrEnd{
3084 .token = token_index,
3085 .end_id = end,
3086 } } };
3203 return ExpectCommaOrEndResult{
3204 .parse_error = Error{
3205 .ExpectedCommaOrEnd = Error.ExpectedCommaOrEnd{
3206 .token = token_index,
3207 .end_id = end,
3208 },
3209 },
3210 };
30873211 },
30883212 }
30893213}
......@@ -3167,13 +3291,14 @@ fn tokenIdToPrefixOp(id: @TagType(Token.Id)) ?ast.Node.PrefixOp.Op {
31673291 Token.Id.Tilde => ast.Node.PrefixOp.Op{ .BitNot = void{} },
31683292 Token.Id.Minus => ast.Node.PrefixOp.Op{ .Negation = void{} },
31693293 Token.Id.MinusPercent => ast.Node.PrefixOp.Op{ .NegationWrap = void{} },
3170 Token.Id.Asterisk,
3171 Token.Id.AsteriskAsterisk => ast.Node.PrefixOp.Op{ .PointerType = void{} },
3172 Token.Id.Ampersand => ast.Node.PrefixOp.Op{ .AddrOf = ast.Node.PrefixOp.AddrOfInfo{
3173 .align_info = null,
3174 .const_token = null,
3175 .volatile_token = null,
3176 } },
3294 Token.Id.Asterisk, Token.Id.AsteriskAsterisk => ast.Node.PrefixOp.Op{ .PointerType = void{} },
3295 Token.Id.Ampersand => ast.Node.PrefixOp.Op{
3296 .AddrOf = ast.Node.PrefixOp.AddrOfInfo{
3297 .align_info = null,
3298 .const_token = null,
3299 .volatile_token = null,
3300 },
3301 },
31773302 Token.Id.QuestionMark => ast.Node.PrefixOp.Op{ .MaybeType = void{} },
31783303 Token.Id.QuestionMarkQuestionMark => ast.Node.PrefixOp.Op{ .UnwrapMaybe = void{} },
31793304 Token.Id.Keyword_await => ast.Node.PrefixOp.Op{ .Await = void{} },
std/zig/parser_test.zig+13-9
......@@ -1021,7 +1021,7 @@ test "zig fmt: extern declaration" {
10211021}
10221022
10231023test "zig fmt: alignment" {
1024 try testCanonical(
1024 try testCanonical(
10251025 \\var foo: c_int align(1);
10261026 \\
10271027 );
......@@ -1070,7 +1070,7 @@ test "zig fmt: slice attributes" {
10701070}
10711071
10721072test "zig fmt: test declaration" {
1073 try testCanonical(
1073 try testCanonical(
10741074 \\test "test name" {
10751075 \\ const a = 1;
10761076 \\ var b = 1;
......@@ -1312,7 +1312,7 @@ test "zig fmt: struct declaration" {
13121312}
13131313
13141314test "zig fmt: enum declaration" {
1315 try testCanonical(
1315 try testCanonical(
13161316 \\const E = enum {
13171317 \\ Ok,
13181318 \\ SomethingElse = 0,
......@@ -1340,7 +1340,7 @@ test "zig fmt: enum declaration" {
13401340}
13411341
13421342test "zig fmt: union declaration" {
1343 try testCanonical(
1343 try testCanonical(
13441344 \\const U = union {
13451345 \\ Int: u8,
13461346 \\ Float: f32,
......@@ -1860,10 +1860,15 @@ fn testTransform(source: []const u8, expected_source: []const u8) !void {
18601860 } else |err| switch (err) {
18611861 error.OutOfMemory => {
18621862 if (failing_allocator.allocated_bytes != failing_allocator.freed_bytes) {
1863 warn("\nfail_index: {}/{}\nallocated bytes: {}\nfreed bytes: {}\nallocations: {}\ndeallocations: {}\n",
1864 fail_index, needed_alloc_count,
1865 failing_allocator.allocated_bytes, failing_allocator.freed_bytes,
1866 failing_allocator.index, failing_allocator.deallocations);
1863 warn(
1864 "\nfail_index: {}/{}\nallocated bytes: {}\nfreed bytes: {}\nallocations: {}\ndeallocations: {}\n",
1865 fail_index,
1866 needed_alloc_count,
1867 failing_allocator.allocated_bytes,
1868 failing_allocator.freed_bytes,
1869 failing_allocator.index,
1870 failing_allocator.deallocations,
1871 );
18671872 return error.MemoryLeakDetected;
18681873 }
18691874 },
......@@ -1876,4 +1881,3 @@ fn testTransform(source: []const u8, expected_source: []const u8) !void {
18761881fn testCanonical(source: []const u8) !void {
18771882 return testTransform(source, source);
18781883}
1879
std/zig/render.zig+48-12
......@@ -161,7 +161,15 @@ fn renderTopLevelDecl(allocator: &mem.Allocator, stream: var, tree: &ast.Tree, i
161161 }
162162}
163163
164fn renderExpression(allocator: &mem.Allocator, stream: var, tree: &ast.Tree, indent: usize, start_col: &usize, base: &ast.Node, space: Space,) (@typeOf(stream).Child.Error || Error)!void {
164fn renderExpression(
165 allocator: &mem.Allocator,
166 stream: var,
167 tree: &ast.Tree,
168 indent: usize,
169 start_col: &usize,
170 base: &ast.Node,
171 space: Space,
172) (@typeOf(stream).Child.Error || Error)!void {
165173 switch (base.id) {
166174 ast.Node.Id.Identifier => {
167175 const identifier = @fieldParentPtr(ast.Node.Identifier, "base", base);
......@@ -259,8 +267,7 @@ fn renderExpression(allocator: &mem.Allocator, stream: var, tree: &ast.Tree, ind
259267 try renderExpression(allocator, stream, tree, indent, start_col, infix_op_node.lhs, op_space);
260268
261269 const after_op_space = blk: {
262 const loc = tree.tokenLocation(tree.tokens.at(infix_op_node.op_token).end,
263 tree.nextToken(infix_op_node.op_token));
270 const loc = tree.tokenLocation(tree.tokens.at(infix_op_node.op_token).end, tree.nextToken(infix_op_node.op_token));
264271 break :blk if (loc.line == 0) op_space else Space.Newline;
265272 };
266273
......@@ -367,14 +374,16 @@ fn renderExpression(allocator: &mem.Allocator, stream: var, tree: &ast.Tree, ind
367374 ast.Node.PrefixOp.Op.NegationWrap,
368375 ast.Node.PrefixOp.Op.UnwrapMaybe,
369376 ast.Node.PrefixOp.Op.MaybeType,
370 ast.Node.PrefixOp.Op.PointerType => {
377 ast.Node.PrefixOp.Op.PointerType,
378 => {
371379 try renderToken(tree, stream, prefix_op_node.op_token, indent, start_col, Space.None);
372380 },
373381
374382 ast.Node.PrefixOp.Op.Try,
375383 ast.Node.PrefixOp.Op.Await,
376384 ast.Node.PrefixOp.Op.Cancel,
377 ast.Node.PrefixOp.Op.Resume => {
385 ast.Node.PrefixOp.Op.Resume,
386 => {
378387 try renderToken(tree, stream, prefix_op_node.op_token, indent, start_col, Space.Space);
379388 },
380389 }
......@@ -1568,13 +1577,19 @@ fn renderExpression(allocator: &mem.Allocator, stream: var, tree: &ast.Tree, ind
15681577 ast.Node.Id.VarDecl,
15691578 ast.Node.Id.Use,
15701579 ast.Node.Id.TestDecl,
1571 ast.Node.Id.ParamDecl => unreachable,
1580 ast.Node.Id.ParamDecl,
1581 => unreachable,
15721582 }
15731583}
15741584
1575fn renderVarDecl(allocator: &mem.Allocator, stream: var, tree: &ast.Tree, indent: usize, start_col: &usize,
1576 var_decl: &ast.Node.VarDecl,) (@typeOf(stream).Child.Error || Error)!void
1577{
1585fn renderVarDecl(
1586 allocator: &mem.Allocator,
1587 stream: var,
1588 tree: &ast.Tree,
1589 indent: usize,
1590 start_col: &usize,
1591 var_decl: &ast.Node.VarDecl,
1592) (@typeOf(stream).Child.Error || Error)!void {
15781593 if (var_decl.visib_token) |visib_token| {
15791594 try renderToken(tree, stream, visib_token, indent, start_col, Space.Space); // pub
15801595 }
......@@ -1623,7 +1638,15 @@ fn renderVarDecl(allocator: &mem.Allocator, stream: var, tree: &ast.Tree, indent
16231638 try renderToken(tree, stream, var_decl.semicolon_token, indent, start_col, Space.Newline);
16241639}
16251640
1626fn renderParamDecl(allocator: &mem.Allocator, stream: var, tree: &ast.Tree, indent: usize, start_col: &usize, base: &ast.Node, space: Space,) (@typeOf(stream).Child.Error || Error)!void {
1641fn renderParamDecl(
1642 allocator: &mem.Allocator,
1643 stream: var,
1644 tree: &ast.Tree,
1645 indent: usize,
1646 start_col: &usize,
1647 base: &ast.Node,
1648 space: Space,
1649) (@typeOf(stream).Child.Error || Error)!void {
16271650 const param_decl = @fieldParentPtr(ast.Node.ParamDecl, "base", base);
16281651
16291652 if (param_decl.comptime_token) |comptime_token| {
......@@ -1643,7 +1666,14 @@ fn renderParamDecl(allocator: &mem.Allocator, stream: var, tree: &ast.Tree, inde
16431666 }
16441667}
16451668
1646fn renderStatement(allocator: &mem.Allocator, stream: var, tree: &ast.Tree, indent: usize, start_col: &usize, base: &ast.Node,) (@typeOf(stream).Child.Error || Error)!void {
1669fn renderStatement(
1670 allocator: &mem.Allocator,
1671 stream: var,
1672 tree: &ast.Tree,
1673 indent: usize,
1674 start_col: &usize,
1675 base: &ast.Node,
1676) (@typeOf(stream).Child.Error || Error)!void {
16471677 switch (base.id) {
16481678 ast.Node.Id.VarDecl => {
16491679 const var_decl = @fieldParentPtr(ast.Node.VarDecl, "base", base);
......@@ -1840,7 +1870,13 @@ fn renderToken(tree: &ast.Tree, stream: var, token_index: ast.TokenIndex, indent
18401870 }
18411871}
18421872
1843fn renderDocComments(tree: &ast.Tree, stream: var, node: var, indent: usize, start_col: &usize,) (@typeOf(stream).Child.Error || Error)!void {
1873fn renderDocComments(
1874 tree: &ast.Tree,
1875 stream: var,
1876 node: var,
1877 indent: usize,
1878 start_col: &usize,
1879) (@typeOf(stream).Child.Error || Error)!void {
18441880 const comment = node.doc_comments ?? return;
18451881 var it = comment.lines.iterator(0);
18461882 const first_token = node.firstToken();
std/zig/tokenizer.zig+101-101
......@@ -11,55 +11,55 @@ pub const Token = struct {
1111 id: Id,
1212 };
1313
14 pub const keywords = []Keyword {
15 Keyword{.bytes="align", .id = Id.Keyword_align},
16 Keyword{.bytes="and", .id = Id.Keyword_and},
17 Keyword{.bytes="asm", .id = Id.Keyword_asm},
18 Keyword{.bytes="async", .id = Id.Keyword_async},
19 Keyword{.bytes="await", .id = Id.Keyword_await},
20 Keyword{.bytes="break", .id = Id.Keyword_break},
21 Keyword{.bytes="catch", .id = Id.Keyword_catch},
22 Keyword{.bytes="cancel", .id = Id.Keyword_cancel},
23 Keyword{.bytes="comptime", .id = Id.Keyword_comptime},
24 Keyword{.bytes="const", .id = Id.Keyword_const},
25 Keyword{.bytes="continue", .id = Id.Keyword_continue},
26 Keyword{.bytes="defer", .id = Id.Keyword_defer},
27 Keyword{.bytes="else", .id = Id.Keyword_else},
28 Keyword{.bytes="enum", .id = Id.Keyword_enum},
29 Keyword{.bytes="errdefer", .id = Id.Keyword_errdefer},
30 Keyword{.bytes="error", .id = Id.Keyword_error},
31 Keyword{.bytes="export", .id = Id.Keyword_export},
32 Keyword{.bytes="extern", .id = Id.Keyword_extern},
33 Keyword{.bytes="false", .id = Id.Keyword_false},
34 Keyword{.bytes="fn", .id = Id.Keyword_fn},
35 Keyword{.bytes="for", .id = Id.Keyword_for},
36 Keyword{.bytes="if", .id = Id.Keyword_if},
37 Keyword{.bytes="inline", .id = Id.Keyword_inline},
38 Keyword{.bytes="nakedcc", .id = Id.Keyword_nakedcc},
39 Keyword{.bytes="noalias", .id = Id.Keyword_noalias},
40 Keyword{.bytes="null", .id = Id.Keyword_null},
41 Keyword{.bytes="or", .id = Id.Keyword_or},
42 Keyword{.bytes="packed", .id = Id.Keyword_packed},
43 Keyword{.bytes="promise", .id = Id.Keyword_promise},
44 Keyword{.bytes="pub", .id = Id.Keyword_pub},
45 Keyword{.bytes="resume", .id = Id.Keyword_resume},
46 Keyword{.bytes="return", .id = Id.Keyword_return},
47 Keyword{.bytes="section", .id = Id.Keyword_section},
48 Keyword{.bytes="stdcallcc", .id = Id.Keyword_stdcallcc},
49 Keyword{.bytes="struct", .id = Id.Keyword_struct},
50 Keyword{.bytes="suspend", .id = Id.Keyword_suspend},
51 Keyword{.bytes="switch", .id = Id.Keyword_switch},
52 Keyword{.bytes="test", .id = Id.Keyword_test},
53 Keyword{.bytes="this", .id = Id.Keyword_this},
54 Keyword{.bytes="true", .id = Id.Keyword_true},
55 Keyword{.bytes="try", .id = Id.Keyword_try},
56 Keyword{.bytes="undefined", .id = Id.Keyword_undefined},
57 Keyword{.bytes="union", .id = Id.Keyword_union},
58 Keyword{.bytes="unreachable", .id = Id.Keyword_unreachable},
59 Keyword{.bytes="use", .id = Id.Keyword_use},
60 Keyword{.bytes="var", .id = Id.Keyword_var},
61 Keyword{.bytes="volatile", .id = Id.Keyword_volatile},
62 Keyword{.bytes="while", .id = Id.Keyword_while},
14 pub const keywords = []Keyword{
15 Keyword{ .bytes = "align", .id = Id.Keyword_align },
16 Keyword{ .bytes = "and", .id = Id.Keyword_and },
17 Keyword{ .bytes = "asm", .id = Id.Keyword_asm },
18 Keyword{ .bytes = "async", .id = Id.Keyword_async },
19 Keyword{ .bytes = "await", .id = Id.Keyword_await },
20 Keyword{ .bytes = "break", .id = Id.Keyword_break },
21 Keyword{ .bytes = "catch", .id = Id.Keyword_catch },
22 Keyword{ .bytes = "cancel", .id = Id.Keyword_cancel },
23 Keyword{ .bytes = "comptime", .id = Id.Keyword_comptime },
24 Keyword{ .bytes = "const", .id = Id.Keyword_const },
25 Keyword{ .bytes = "continue", .id = Id.Keyword_continue },
26 Keyword{ .bytes = "defer", .id = Id.Keyword_defer },
27 Keyword{ .bytes = "else", .id = Id.Keyword_else },
28 Keyword{ .bytes = "enum", .id = Id.Keyword_enum },
29 Keyword{ .bytes = "errdefer", .id = Id.Keyword_errdefer },
30 Keyword{ .bytes = "error", .id = Id.Keyword_error },
31 Keyword{ .bytes = "export", .id = Id.Keyword_export },
32 Keyword{ .bytes = "extern", .id = Id.Keyword_extern },
33 Keyword{ .bytes = "false", .id = Id.Keyword_false },
34 Keyword{ .bytes = "fn", .id = Id.Keyword_fn },
35 Keyword{ .bytes = "for", .id = Id.Keyword_for },
36 Keyword{ .bytes = "if", .id = Id.Keyword_if },
37 Keyword{ .bytes = "inline", .id = Id.Keyword_inline },
38 Keyword{ .bytes = "nakedcc", .id = Id.Keyword_nakedcc },
39 Keyword{ .bytes = "noalias", .id = Id.Keyword_noalias },
40 Keyword{ .bytes = "null", .id = Id.Keyword_null },
41 Keyword{ .bytes = "or", .id = Id.Keyword_or },
42 Keyword{ .bytes = "packed", .id = Id.Keyword_packed },
43 Keyword{ .bytes = "promise", .id = Id.Keyword_promise },
44 Keyword{ .bytes = "pub", .id = Id.Keyword_pub },
45 Keyword{ .bytes = "resume", .id = Id.Keyword_resume },
46 Keyword{ .bytes = "return", .id = Id.Keyword_return },
47 Keyword{ .bytes = "section", .id = Id.Keyword_section },
48 Keyword{ .bytes = "stdcallcc", .id = Id.Keyword_stdcallcc },
49 Keyword{ .bytes = "struct", .id = Id.Keyword_struct },
50 Keyword{ .bytes = "suspend", .id = Id.Keyword_suspend },
51 Keyword{ .bytes = "switch", .id = Id.Keyword_switch },
52 Keyword{ .bytes = "test", .id = Id.Keyword_test },
53 Keyword{ .bytes = "this", .id = Id.Keyword_this },
54 Keyword{ .bytes = "true", .id = Id.Keyword_true },
55 Keyword{ .bytes = "try", .id = Id.Keyword_try },
56 Keyword{ .bytes = "undefined", .id = Id.Keyword_undefined },
57 Keyword{ .bytes = "union", .id = Id.Keyword_union },
58 Keyword{ .bytes = "unreachable", .id = Id.Keyword_unreachable },
59 Keyword{ .bytes = "use", .id = Id.Keyword_use },
60 Keyword{ .bytes = "var", .id = Id.Keyword_var },
61 Keyword{ .bytes = "volatile", .id = Id.Keyword_volatile },
62 Keyword{ .bytes = "while", .id = Id.Keyword_while },
6363 };
6464
6565 // TODO perfect hash at comptime
......@@ -72,7 +72,10 @@ pub const Token = struct {
7272 return null;
7373 }
7474
75 const StrLitKind = enum {Normal, C};
75 const StrLitKind = enum {
76 Normal,
77 C,
78 };
7679
7780 pub const Id = union(enum) {
7881 Invalid,
......@@ -202,7 +205,7 @@ pub const Tokenizer = struct {
202205 }
203206
204207 pub fn init(buffer: []const u8) Tokenizer {
205 return Tokenizer {
208 return Tokenizer{
206209 .buffer = buffer,
207210 .index = 0,
208211 .pending_invalid_token = null,
......@@ -269,7 +272,7 @@ pub const Tokenizer = struct {
269272 }
270273 const start_index = self.index;
271274 var state = State.Start;
272 var result = Token {
275 var result = Token{
273276 .id = Token.Id.Eof,
274277 .start = self.index,
275278 .end = undefined,
......@@ -290,7 +293,7 @@ pub const Tokenizer = struct {
290293 },
291294 '"' => {
292295 state = State.StringLiteral;
293 result.id = Token.Id { .StringLiteral = Token.StrLitKind.Normal };
296 result.id = Token.Id{ .StringLiteral = Token.StrLitKind.Normal };
294297 },
295298 '\'' => {
296299 state = State.CharLiteral;
......@@ -369,7 +372,7 @@ pub const Tokenizer = struct {
369372 },
370373 '\\' => {
371374 state = State.Backslash;
372 result.id = Token.Id { .MultilineStringLiteralLine = Token.StrLitKind.Normal };
375 result.id = Token.Id{ .MultilineStringLiteralLine = Token.StrLitKind.Normal };
373376 },
374377 '{' => {
375378 result.id = Token.Id.LBrace;
......@@ -455,7 +458,7 @@ pub const Tokenizer = struct {
455458 else => {
456459 result.id = Token.Id.Asterisk;
457460 break;
458 }
461 },
459462 },
460463
461464 State.AsteriskPercent => switch (c) {
......@@ -467,7 +470,7 @@ pub const Tokenizer = struct {
467470 else => {
468471 result.id = Token.Id.AsteriskPercent;
469472 break;
470 }
473 },
471474 },
472475
473476 State.QuestionMark => switch (c) {
......@@ -535,7 +538,7 @@ pub const Tokenizer = struct {
535538 else => {
536539 result.id = Token.Id.Caret;
537540 break;
538 }
541 },
539542 },
540543
541544 State.Identifier => switch (c) {
......@@ -560,11 +563,11 @@ pub const Tokenizer = struct {
560563 State.C => switch (c) {
561564 '\\' => {
562565 state = State.Backslash;
563 result.id = Token.Id { .MultilineStringLiteralLine = Token.StrLitKind.C };
566 result.id = Token.Id{ .MultilineStringLiteralLine = Token.StrLitKind.C };
564567 },
565568 '"' => {
566569 state = State.StringLiteral;
567 result.id = Token.Id { .StringLiteral = Token.StrLitKind.C };
570 result.id = Token.Id{ .StringLiteral = Token.StrLitKind.C };
568571 },
569572 'a'...'z', 'A'...'Z', '_', '0'...'9' => {
570573 state = State.Identifier;
......@@ -605,7 +608,7 @@ pub const Tokenizer = struct {
605608 }
606609
607610 state = State.CharLiteralEnd;
608 }
611 },
609612 },
610613
611614 State.CharLiteralBackslash => switch (c) {
......@@ -736,7 +739,7 @@ pub const Tokenizer = struct {
736739 else => {
737740 result.id = Token.Id.MinusPercent;
738741 break;
739 }
742 },
740743 },
741744
742745 State.AngleBracketLeft => switch (c) {
......@@ -944,7 +947,7 @@ pub const Tokenizer = struct {
944947 // reinterpret as a normal exponent number
945948 self.index -= 1;
946949 state = State.FloatExponentNumber;
947 }
950 },
948951 },
949952 State.FloatExponentUnsignedHex => switch (c) {
950953 '+', '-' => {
......@@ -954,7 +957,7 @@ pub const Tokenizer = struct {
954957 // reinterpret as a normal exponent number
955958 self.index -= 1;
956959 state = State.FloatExponentNumberHex;
957 }
960 },
958961 },
959962 State.FloatExponentNumber => switch (c) {
960963 '0'...'9' => {},
......@@ -978,15 +981,15 @@ pub const Tokenizer = struct {
978981 State.FloatExponentNumberHex,
979982 State.StringLiteral, // find this error later
980983 State.MultilineStringLiteralLine,
981 State.Builtin => {},
984 State.Builtin,
985 => {},
982986
983987 State.Identifier => {
984988 if (Token.getKeyword(self.buffer[result.start..self.index])) |id| {
985989 result.id = id;
986990 }
987991 },
988 State.LineCommentStart,
989 State.LineComment => {
992 State.LineCommentStart, State.LineComment => {
990993 result.id = Token.Id.LineComment;
991994 },
992995 State.DocComment, State.DocCommentStart => {
......@@ -1004,7 +1007,8 @@ pub const Tokenizer = struct {
10041007 State.CharLiteralEscape1,
10051008 State.CharLiteralEscape2,
10061009 State.CharLiteralEnd,
1007 State.StringLiteralBackslash => {
1010 State.StringLiteralBackslash,
1011 => {
10081012 result.id = Token.Id.Invalid;
10091013 },
10101014
......@@ -1089,7 +1093,7 @@ pub const Tokenizer = struct {
10891093 if (self.pending_invalid_token != null) return;
10901094 const invalid_length = self.getInvalidCharacterLength();
10911095 if (invalid_length == 0) return;
1092 self.pending_invalid_token = Token {
1096 self.pending_invalid_token = Token{
10931097 .id = Token.Id.Invalid,
10941098 .start = self.index,
10951099 .end = self.index + invalid_length,
......@@ -1134,23 +1138,18 @@ pub const Tokenizer = struct {
11341138 }
11351139};
11361140
1137
1138
11391141test "tokenizer" {
1140 testTokenize("test", []Token.Id {
1141 Token.Id.Keyword_test,
1142 });
1142 testTokenize("test", []Token.Id{Token.Id.Keyword_test});
11431143}
11441144
11451145test "tokenizer - char literal with hex escape" {
1146 testTokenize( \\'\x1b'
1147 , []Token.Id {
1148 Token.Id.CharLiteral,
1149 });
1146 testTokenize(
1147 \\'\x1b'
1148 , []Token.Id{Token.Id.CharLiteral});
11501149}
11511150
11521151test "tokenizer - float literal e exponent" {
1153 testTokenize("a = 4.94065645841246544177e-324;\n", []Token.Id {
1152 testTokenize("a = 4.94065645841246544177e-324;\n", []Token.Id{
11541153 Token.Id.Identifier,
11551154 Token.Id.Equal,
11561155 Token.Id.FloatLiteral,
......@@ -1159,7 +1158,7 @@ test "tokenizer - float literal e exponent" {
11591158}
11601159
11611160test "tokenizer - float literal p exponent" {
1162 testTokenize("a = 0x1.a827999fcef32p+1022;\n", []Token.Id {
1161 testTokenize("a = 0x1.a827999fcef32p+1022;\n", []Token.Id{
11631162 Token.Id.Identifier,
11641163 Token.Id.Equal,
11651164 Token.Id.FloatLiteral,
......@@ -1168,31 +1167,31 @@ test "tokenizer - float literal p exponent" {
11681167}
11691168
11701169test "tokenizer - chars" {
1171 testTokenize("'c'", []Token.Id {Token.Id.CharLiteral});
1170 testTokenize("'c'", []Token.Id{Token.Id.CharLiteral});
11721171}
11731172
11741173test "tokenizer - invalid token characters" {
11751174 testTokenize("#", []Token.Id{Token.Id.Invalid});
11761175 testTokenize("`", []Token.Id{Token.Id.Invalid});
1177 testTokenize("'c", []Token.Id {Token.Id.Invalid});
1178 testTokenize("'", []Token.Id {Token.Id.Invalid});
1179 testTokenize("''", []Token.Id {Token.Id.Invalid, Token.Id.Invalid});
1176 testTokenize("'c", []Token.Id{Token.Id.Invalid});
1177 testTokenize("'", []Token.Id{Token.Id.Invalid});
1178 testTokenize("''", []Token.Id{ Token.Id.Invalid, Token.Id.Invalid });
11801179}
11811180
11821181test "tokenizer - invalid literal/comment characters" {
1183 testTokenize("\"\x00\"", []Token.Id {
1184 Token.Id { .StringLiteral = Token.StrLitKind.Normal },
1182 testTokenize("\"\x00\"", []Token.Id{
1183 Token.Id{ .StringLiteral = Token.StrLitKind.Normal },
11851184 Token.Id.Invalid,
11861185 });
1187 testTokenize("//\x00", []Token.Id {
1186 testTokenize("//\x00", []Token.Id{
11881187 Token.Id.LineComment,
11891188 Token.Id.Invalid,
11901189 });
1191 testTokenize("//\x1f", []Token.Id {
1190 testTokenize("//\x1f", []Token.Id{
11921191 Token.Id.LineComment,
11931192 Token.Id.Invalid,
11941193 });
1195 testTokenize("//\x7f", []Token.Id {
1194 testTokenize("//\x7f", []Token.Id{
11961195 Token.Id.LineComment,
11971196 Token.Id.Invalid,
11981197 });
......@@ -1261,18 +1260,16 @@ test "tokenizer - illegal unicode codepoints" {
12611260test "tokenizer - string identifier and builtin fns" {
12621261 testTokenize(
12631262 \\const @"if" = @import("std");
1264 ,
1265 []Token.Id{
1266 Token.Id.Keyword_const,
1267 Token.Id.Identifier,
1268 Token.Id.Equal,
1269 Token.Id.Builtin,
1270 Token.Id.LParen,
1271 Token.Id {.StringLiteral = Token.StrLitKind.Normal},
1272 Token.Id.RParen,
1273 Token.Id.Semicolon,
1274 }
1275 );
1263 , []Token.Id{
1264 Token.Id.Keyword_const,
1265 Token.Id.Identifier,
1266 Token.Id.Equal,
1267 Token.Id.Builtin,
1268 Token.Id.LParen,
1269 Token.Id{ .StringLiteral = Token.StrLitKind.Normal },
1270 Token.Id.RParen,
1271 Token.Id.Semicolon,
1272 });
12761273}
12771274
12781275test "tokenizer - pipe and then invalid" {
......@@ -1314,7 +1311,10 @@ fn testTokenize(source: []const u8, expected_tokens: []const Token.Id) void {
13141311 }
13151312 switch (expected_token_id) {
13161313 Token.Id.StringLiteral => |expected_kind| {
1317 std.debug.assert(expected_kind == switch (token.id) { Token.Id.StringLiteral => |kind| kind, else => unreachable });
1314 std.debug.assert(expected_kind == switch (token.id) {
1315 Token.Id.StringLiteral => |kind| kind,
1316 else => unreachable,
1317 });
13181318 },
13191319 else => {},
13201320 }
test/cases/align.zig+6-6
......@@ -70,7 +70,7 @@ test "specifying alignment allows pointer cast" {
7070 testBytesAlign(0x33);
7171}
7272fn testBytesAlign(b: u8) void {
73 var bytes align(4) = []u8 {
73 var bytes align(4) = []u8{
7474 b,
7575 b,
7676 b,
......@@ -84,7 +84,7 @@ test "specifying alignment allows slice cast" {
8484 testBytesAlignSlice(0x33);
8585}
8686fn testBytesAlignSlice(b: u8) void {
87 var bytes align(4) = []u8 {
87 var bytes align(4) = []u8{
8888 b,
8989 b,
9090 b,
......@@ -107,7 +107,7 @@ fn expects4(x: &align(4) u32) void {
107107}
108108
109109test "@alignCast slices" {
110 var array align(4) = []u32 {
110 var array align(4) = []u32{
111111 1,
112112 1,
113113 };
......@@ -169,7 +169,7 @@ test "@ptrCast preserves alignment of bigger source" {
169169
170170test "compile-time known array index has best alignment possible" {
171171 // take full advantage of over-alignment
172 var array align(4) = []u8 {
172 var array align(4) = []u8{
173173 1,
174174 2,
175175 3,
......@@ -181,7 +181,7 @@ test "compile-time known array index has best alignment possible" {
181181 assert(@typeOf(&array[3]) == &u8);
182182
183183 // because align is too small but we still figure out to use 2
184 var bigger align(2) = []u64 {
184 var bigger align(2) = []u64{
185185 1,
186186 2,
187187 3,
......@@ -193,7 +193,7 @@ test "compile-time known array index has best alignment possible" {
193193 assert(@typeOf(&bigger[3]) == &align(2) u64);
194194
195195 // because pointer is align 2 and u32 align % 2 == 0 we can assume align 2
196 var smaller align(2) = []u32 {
196 var smaller align(2) = []u32{
197197 1,
198198 2,
199199 3,
test/cases/array.zig+5-7
......@@ -34,7 +34,7 @@ test "void arrays" {
3434}
3535
3636test "array literal" {
37 const hex_mult = []u16 {
37 const hex_mult = []u16{
3838 4096,
3939 256,
4040 16,
......@@ -54,7 +54,7 @@ test "array dot len const expr" {
5454const ArrayDotLenConstExpr = struct {
5555 y: [some_array.len]u8,
5656};
57const some_array = []u8 {
57const some_array = []u8{
5858 0,
5959 1,
6060 2,
......@@ -62,7 +62,7 @@ const some_array = []u8 {
6262};
6363
6464test "nested arrays" {
65 const array_of_strings = [][]const u8 {
65 const array_of_strings = [][]const u8{
6666 "hello",
6767 "this",
6868 "is",
......@@ -86,9 +86,7 @@ const Str = struct {
8686 a: []Sub,
8787};
8888test "set global var array via slice embedded in struct" {
89 var s = Str {
90 .a = s_array[0..],
91 };
89 var s = Str{ .a = s_array[0..] };
9290
9391 s.a[0].b = 1;
9492 s.a[1].b = 2;
......@@ -100,7 +98,7 @@ test "set global var array via slice embedded in struct" {
10098}
10199
102100test "array literal with specified size" {
103 var array = [2]u8 {
101 var array = [2]u8{
104102 1,
105103 2,
106104 };
test/cases/bugs/394.zig+2-4
......@@ -10,11 +10,9 @@ const S = struct {
1010const assert = @import("std").debug.assert;
1111
1212test "bug 394 fixed" {
13 const x = S {
13 const x = S{
1414 .x = 3,
15 .y = E {
16 .B = 1,
17 },
15 .y = E{ .B = 1 },
1816 };
1917 assert(x.x == 3);
2018}
test/cases/bugs/656.zig+2-4
......@@ -14,10 +14,8 @@ test "nullable if after an if in a switch prong of a switch with 2 prongs in an
1414}
1515
1616fn foo(a: bool, b: bool) void {
17 var prefix_op = PrefixOp {
18 .AddrOf = Value {
19 .align_expr = 1234,
20 },
17 var prefix_op = PrefixOp{
18 .AddrOf = Value{ .align_expr = 1234 },
2119 };
2220 if (a) {} else {
2321 switch (prefix_op) {
test/cases/bugs/828.zig+2-6
......@@ -1,14 +1,10 @@
11const CountBy = struct {
22 a: usize,
33
4 const One = CountBy {
5 .a = 1,
6 };
4 const One = CountBy{ .a = 1 };
75
86 pub fn counter(self: &const CountBy) Counter {
9 return Counter {
10 .i = 0,
11 };
7 return Counter{ .i = 0 };
128 }
139};
1410
test/cases/cast.zig+8-23
......@@ -33,27 +33,21 @@ fn funcWithConstPtrPtr(x: &const &i32) void {
3333}
3434
3535test "implicitly cast a container to a const pointer of it" {
36 const z = Struct(void) {
37 .x = void{},
38 };
36 const z = Struct(void){ .x = void{} };
3937 assert(0 == @sizeOf(@typeOf(z)));
4038 assert(void{} == Struct(void).pointer(z).x);
4139 assert(void{} == Struct(void).pointer(&z).x);
4240 assert(void{} == Struct(void).maybePointer(z).x);
4341 assert(void{} == Struct(void).maybePointer(&z).x);
4442 assert(void{} == Struct(void).maybePointer(null).x);
45 const s = Struct(u8) {
46 .x = 42,
47 };
43 const s = Struct(u8){ .x = 42 };
4844 assert(0 != @sizeOf(@typeOf(s)));
4945 assert(42 == Struct(u8).pointer(s).x);
5046 assert(42 == Struct(u8).pointer(&s).x);
5147 assert(42 == Struct(u8).maybePointer(s).x);
5248 assert(42 == Struct(u8).maybePointer(&s).x);
5349 assert(0 == Struct(u8).maybePointer(null).x);
54 const u = Union {
55 .x = 42,
56 };
50 const u = Union{ .x = 42 };
5751 assert(42 == Union.pointer(u).x);
5852 assert(42 == Union.pointer(&u).x);
5953 assert(42 == Union.maybePointer(u).x);
......@@ -77,9 +71,7 @@ fn Struct(comptime T: type) type {
7771 }
7872
7973 fn maybePointer(self: ?&const Self) Self {
80 const none = Self {
81 .x = if (T == void) void{} else 0,
82 };
74 const none = Self{ .x = if (T == void) void{} else 0 };
8375 return (self ?? &none).*;
8476 }
8577 };
......@@ -93,9 +85,7 @@ const Union = union {
9385 }
9486
9587 fn maybePointer(self: ?&const Union) Union {
96 const none = Union {
97 .x = 0,
98 };
88 const none = Union{ .x = 0 };
9989 return (self ?? &none).*;
10090 }
10191};
......@@ -130,9 +120,7 @@ test "implicitly cast indirect pointer to maybe-indirect pointer" {
130120 return ((??p).*.*).x;
131121 }
132122 };
133 const s = S {
134 .x = 42,
135 };
123 const s = S{ .x = 42 };
136124 const p = &s;
137125 const q = &p;
138126 const r = &q;
......@@ -202,9 +190,7 @@ fn castToMaybeTypeError(z: i32) void {
202190 const f = z;
203191 const g: error!?i32 = f;
204192
205 const a = A {
206 .a = z,
207 };
193 const a = A{ .a = z };
208194 const b: error!?A = a;
209195 assert((??(b catch unreachable)).a == 1);
210196}
......@@ -343,7 +329,6 @@ test "peer type resolution: error and [N]T" {
343329 // TODO: implicit error!T to error!U where T can implicitly cast to U
344330 //assert(mem.eql(u8, try testPeerErrorAndArray(0), "OK"));
345331 //comptime assert(mem.eql(u8, try testPeerErrorAndArray(0), "OK"));
346
347332 assert(mem.eql(u8, try testPeerErrorAndArray2(1), "OKK"));
348333 comptime assert(mem.eql(u8, try testPeerErrorAndArray2(1), "OKK"));
349334}
......@@ -387,7 +372,7 @@ fn cast128Float(x: u128) f128 {
387372}
388373
389374test "const slice widen cast" {
390 const bytes align(4) = []u8 {
375 const bytes align(4) = []u8{
391376 0x12,
392377 0x12,
393378 0x12,
test/cases/const_slice_child.zig+1-1
......@@ -4,7 +4,7 @@ const assert = debug.assert;
44var argv: &const &const u8 = undefined;
55
66test "const slice child" {
7 const strs = ([]&const u8) {
7 const strs = ([]&const u8){
88 c"one",
99 c"two",
1010 c"three",
test/cases/coroutines.zig+4-19
......@@ -10,7 +10,6 @@ test "create a coroutine and cancel it" {
1010 cancel p;
1111 assert(x == 2);
1212}
13
1413async fn simpleAsyncFn() void {
1514 x += 1;
1615 suspend;
......@@ -28,7 +27,6 @@ test "coroutine suspend, resume, cancel" {
2827
2928 assert(std.mem.eql(u8, points, "abcdefg"));
3029}
31
3230async fn testAsyncSeq() void {
3331 defer seq('e');
3432
......@@ -36,7 +34,7 @@ async fn testAsyncSeq() void {
3634 suspend;
3735 seq('d');
3836}
39var points = []u8 {0} ** "abcdefg".len;
37var points = []u8{0} ** "abcdefg".len;
4038var index: usize = 0;
4139
4240fn seq(c: u8) void {
......@@ -54,7 +52,6 @@ test "coroutine suspend with block" {
5452
5553var a_promise: promise = undefined;
5654var result = false;
57
5855async fn testSuspendBlock() void {
5956 suspend |p| {
6057 comptime assert(@typeOf(p) == promise->void);
......@@ -75,7 +72,6 @@ test "coroutine await" {
7572 assert(await_final_result == 1234);
7673 assert(std.mem.eql(u8, await_points, "abcdefghi"));
7774}
78
7975async fn await_amain() void {
8076 await_seq('b');
8177 const p = async await_another() catch unreachable;
......@@ -83,7 +79,6 @@ async fn await_amain() void {
8379 await_final_result = await p;
8480 await_seq('h');
8581}
86
8782async fn await_another() i32 {
8883 await_seq('c');
8984 suspend |p| {
......@@ -94,7 +89,7 @@ async fn await_another() i32 {
9489 return 1234;
9590}
9691
97var await_points = []u8 {0} ** "abcdefghi".len;
92var await_points = []u8{0} ** "abcdefghi".len;
9893var await_seq_index: usize = 0;
9994
10095fn await_seq(c: u8) void {
......@@ -111,7 +106,6 @@ test "coroutine await early return" {
111106 assert(early_final_result == 1234);
112107 assert(std.mem.eql(u8, early_points, "abcdef"));
113108}
114
115109async fn early_amain() void {
116110 early_seq('b');
117111 const p = async early_another() catch unreachable;
......@@ -119,13 +113,12 @@ async fn early_amain() void {
119113 early_final_result = await p;
120114 early_seq('e');
121115}
122
123116async fn early_another() i32 {
124117 early_seq('c');
125118 return 1234;
126119}
127120
128var early_points = []u8 {0} ** "abcdef".len;
121var early_points = []u8{0} ** "abcdef".len;
129122var early_seq_index: usize = 0;
130123
131124fn early_seq(c: u8) void {
......@@ -141,7 +134,6 @@ test "coro allocation failure" {
141134 error.OutOfMemory => {},
142135 }
143136}
144
145137async fn asyncFuncThatNeverGetsRun() void {
146138 @panic("coro frame allocation should fail");
147139}
......@@ -164,15 +156,12 @@ test "async fn pointer in a struct field" {
164156 const Foo = struct {
165157 bar: async<&std.mem.Allocator> fn(&i32) void,
166158 };
167 var foo = Foo {
168 .bar = simpleAsyncFn2,
169 };
159 var foo = Foo{ .bar = simpleAsyncFn2 };
170160 const p = (async<std.debug.global_allocator> foo.bar(&data)) catch unreachable;
171161 assert(data == 2);
172162 cancel p;
173163 assert(data == 4);
174164}
175
176165async<&std.mem.Allocator> fn simpleAsyncFn2(y: &i32) void {
177166 defer y.* += 2;
178167 y.* += 1;
......@@ -184,7 +173,6 @@ test "async fn with inferred error set" {
184173 resume p;
185174 cancel p;
186175}
187
188176async fn failing() !void {
189177 suspend;
190178 return error.Fail;
......@@ -208,12 +196,10 @@ test "error return trace across suspend points - async return" {
208196fn nonFailing() (promise->error!void) {
209197 return async<std.debug.global_allocator> suspendThenFail() catch unreachable;
210198}
211
212199async fn suspendThenFail() error!void {
213200 suspend;
214201 return error.Fail;
215202}
216
217203async fn printTrace(p: promise->error!void) void {
218204 (await p) catch |e| {
219205 std.debug.assert(e == error.Fail);
......@@ -234,7 +220,6 @@ test "break from suspend" {
234220 cancel p;
235221 std.debug.assert(my_result == 2);
236222}
237
238223async fn testBreakFromSuspend(my_result: &i32) void {
239224 s: suspend |p| {
240225 break :s;
test/cases/enum.zig+7-15
......@@ -2,11 +2,9 @@ const assert = @import("std").debug.assert;
22const mem = @import("std").mem;
33
44test "enum type" {
5 const foo1 = Foo {
6 .One = 13,
7 };
8 const foo2 = Foo {
9 .Two = Point {
5 const foo1 = Foo{ .One = 13 };
6 const foo2 = Foo{
7 .Two = Point{
108 .x = 1234,
119 .y = 5678,
1210 },
......@@ -48,18 +46,12 @@ const Bar = enum {
4846};
4947
5048fn returnAnInt(x: i32) Foo {
51 return Foo {
52 .One = x,
53 };
49 return Foo{ .One = x };
5450}
5551
5652test "constant enum with payload" {
57 var empty = AnEnumWithPayload {
58 .Empty = {},
59 };
60 var full = AnEnumWithPayload {
61 .Full = 13,
62 };
53 var empty = AnEnumWithPayload{ .Empty = {} };
54 var full = AnEnumWithPayload{ .Full = 13 };
6355 shouldBeEmpty(empty);
6456 shouldBeNotEmpty(full);
6557}
......@@ -737,7 +729,7 @@ const BitFieldOfEnums = packed struct {
737729 c: C,
738730};
739731
740const bit_field_1 = BitFieldOfEnums {
732const bit_field_1 = BitFieldOfEnums{
741733 .a = A.Two,
742734 .b = B.Three3,
743735 .c = C.Four4,
test/cases/enum_with_members.zig+2-6
......@@ -15,12 +15,8 @@ const ET = union(enum) {
1515};
1616
1717test "enum with members" {
18 const a = ET {
19 .SINT = -42,
20 };
21 const b = ET {
22 .UINT = 42,
23 };
18 const a = ET{ .SINT = -42 };
19 const b = ET{ .UINT = 42 };
2420 var buf: [20]u8 = undefined;
2521
2622 assert((a.print(buf[0..]) catch unreachable) == 3);
test/cases/error.zig+10-12
......@@ -92,7 +92,7 @@ test "error set type " {
9292 comptime testErrorSetType();
9393}
9494
95const MyErrSet = error {
95const MyErrSet = error{
9696 OutOfMemory,
9797 FileNotFound,
9898};
......@@ -114,11 +114,11 @@ test "explicit error set cast" {
114114 comptime testExplicitErrorSetCast(Set1.A);
115115}
116116
117const Set1 = error {
117const Set1 = error{
118118 A,
119119 B,
120120};
121const Set2 = error {
121const Set2 = error{
122122 A,
123123 C,
124124};
......@@ -134,8 +134,7 @@ test "comptime test error for empty error set" {
134134 comptime testComptimeTestErrorEmptySet(1234);
135135}
136136
137const EmptyErrorSet = error {
138};
137const EmptyErrorSet = error{};
139138
140139fn testComptimeTestErrorEmptySet(x: EmptyErrorSet!i32) void {
141140 if (x) |v| assert(v == 1234) else |err| @compileError("bad");
......@@ -151,9 +150,10 @@ test "comptime err to int of error set with only 1 possible value" {
151150 testErrToIntWithOnePossibleValue(error.A, u32(error.A));
152151 comptime testErrToIntWithOnePossibleValue(error.A, u32(error.A));
153152}
154fn testErrToIntWithOnePossibleValue(x: error {
155 A,
156}, comptime value: u32) void {
153fn testErrToIntWithOnePossibleValue(
154 x: error{A},
155 comptime value: u32,
156) void {
157157 if (u32(x) != value) {
158158 @compileError("bad");
159159 }
......@@ -197,16 +197,14 @@ fn foo2(f: fn() error!void) void {
197197 const x = f();
198198}
199199
200fn bar2() (error {
201}!void) {}
200fn bar2() (error{}!void) {}
202201
203202test "error: Zero sized error set returned with value payload crash" {
204203 _ = foo3(0);
205204 _ = comptime foo3(0);
206205}
207206
208const Error = error {
209};
207const Error = error{};
210208fn foo3(b: usize) Error!usize {
211209 return b;
212210}
test/cases/eval.zig+21-31
......@@ -72,12 +72,12 @@ const Point = struct {
7272 x: i32,
7373 y: i32,
7474};
75const static_point_list = []Point {
75const static_point_list = []Point{
7676 makePoint(1, 2),
7777 makePoint(3, 4),
7878};
7979fn makePoint(x: i32, y: i32) Point {
80 return Point {
80 return Point{
8181 .x = x,
8282 .y = y,
8383 };
......@@ -92,13 +92,11 @@ pub const Vec3 = struct {
9292 data: [3]f32,
9393};
9494pub fn vec3(x: f32, y: f32, z: f32) Vec3 {
95 return Vec3 {
96 .data = []f32 {
97 x,
98 y,
99 z,
100 },
101 };
95 return Vec3{ .data = []f32{
96 x,
97 y,
98 z,
99 } };
102100}
103101
104102test "constant expressions" {
......@@ -117,22 +115,22 @@ const Vertex = struct {
117115 g: f32,
118116 b: f32,
119117};
120const vertices = []Vertex {
121 Vertex {
118const vertices = []Vertex{
119 Vertex{
122120 .x = -0.6,
123121 .y = -0.4,
124122 .r = 1.0,
125123 .g = 0.0,
126124 .b = 0.0,
127125 },
128 Vertex {
126 Vertex{
129127 .x = 0.6,
130128 .y = -0.4,
131129 .r = 0.0,
132130 .g = 1.0,
133131 .b = 0.0,
134132 },
135 Vertex {
133 Vertex{
136134 .x = 0.0,
137135 .y = 0.6,
138136 .r = 0.0,
......@@ -149,7 +147,7 @@ const StInitStrFoo = struct {
149147 x: i32,
150148 y: bool,
151149};
152var st_init_str_foo = StInitStrFoo {
150var st_init_str_foo = StInitStrFoo{
153151 .x = 13,
154152 .y = true,
155153};
......@@ -158,7 +156,7 @@ test "statically initalized array literal" {
158156 const y: [4]u8 = st_init_arr_lit_x;
159157 assert(y[3] == 4);
160158}
161const st_init_arr_lit_x = []u8 {
159const st_init_arr_lit_x = []u8{
162160 1,
163161 2,
164162 3,
......@@ -220,16 +218,16 @@ const CmdFn = struct {
220218 func: fn(i32) i32,
221219};
222220
223const cmd_fns = []CmdFn {
224 CmdFn {
221const cmd_fns = []CmdFn{
222 CmdFn{
225223 .name = "one",
226224 .func = one,
227225 },
228 CmdFn {
226 CmdFn{
229227 .name = "two",
230228 .func = two,
231229 },
232 CmdFn {
230 CmdFn{
233231 .name = "three",
234232 .func = three,
235233 },
......@@ -289,9 +287,7 @@ const SimpleStruct = struct {
289287 }
290288};
291289
292var simple_struct = SimpleStruct {
293 .field = 1234,
294};
290var simple_struct = SimpleStruct{ .field = 1234 };
295291
296292const bound_fn = simple_struct.method;
297293
......@@ -341,9 +337,7 @@ const Foo = struct {
341337 name: []const u8,
342338};
343339
344var foo_contents = Foo {
345 .name = "a",
346};
340var foo_contents = Foo{ .name = "a" };
347341const foo_ref = &foo_contents;
348342
349343test "create global array with for loop" {
......@@ -529,9 +523,7 @@ const SingleFieldStruct = struct {
529523};
530524test "const ptr to comptime mutable data is not memoized" {
531525 comptime {
532 var foo = SingleFieldStruct {
533 .x = 1,
534 };
526 var foo = SingleFieldStruct{ .x = 1 };
535527 assert(foo.read_x() == 1);
536528 foo.x = 2;
537529 assert(foo.read_x() == 2);
......@@ -574,9 +566,7 @@ pub const Info = struct {
574566 version: u8,
575567};
576568
577pub const diamond_info = Info {
578 .version = 0,
579};
569pub const diamond_info = Info{ .version = 0 };
580570
581571test "comptime modification of const struct field" {
582572 comptime {
test/cases/field_parent_ptr.zig+1-1
......@@ -17,7 +17,7 @@ const Foo = struct {
1717 d: i32,
1818};
1919
20const foo = Foo {
20const foo = Foo{
2121 .a = true,
2222 .b = 0.123,
2323 .c = 1234,
test/cases/fn.zig+1-1
......@@ -73,7 +73,7 @@ fn fnWithUnreachable() noreturn {
7373}
7474
7575test "function pointers" {
76 const fns = []@typeOf(fn1) {
76 const fns = []@typeOf(fn1){
7777 fn1,
7878 fn2,
7979 fn3,
test/cases/fn_in_struct_in_comptime.zig+1-1
......@@ -1,6 +1,6 @@
11const assert = @import("std").debug.assert;
22
3fn get_foo() fn(&u8)usize {
3fn get_foo() fn(&u8) usize {
44 comptime {
55 return struct {
66 fn func(ptr: &u8) usize {
test/cases/for.zig+3-3
......@@ -3,7 +3,7 @@ const assert = std.debug.assert;
33const mem = std.mem;
44
55test "continue in for loop" {
6 const array = []i32 {
6 const array = []i32{
77 1,
88 2,
99 3,
......@@ -35,7 +35,7 @@ fn mangleString(s: []u8) void {
3535}
3636
3737test "basic for loop" {
38 const expected_result = []u8 {
38 const expected_result = []u8{
3939 9,
4040 8,
4141 7,
......@@ -57,7 +57,7 @@ test "basic for loop" {
5757 var buffer: [expected_result.len]u8 = undefined;
5858 var buf_index: usize = 0;
5959
60 const array = []u8 {
60 const array = []u8{
6161 9,
6262 8,
6363 7,
test/cases/generics.zig+5-5
......@@ -81,11 +81,11 @@ test "function with return type type" {
8181}
8282
8383test "generic struct" {
84 var a1 = GenNode(i32) {
84 var a1 = GenNode(i32){
8585 .value = 13,
8686 .next = null,
8787 };
88 var b1 = GenNode(bool) {
88 var b1 = GenNode(bool){
8989 .value = true,
9090 .next = null,
9191 };
......@@ -120,8 +120,8 @@ fn aGenericFn(comptime T: type, comptime a: T, b: T) T {
120120}
121121
122122test "generic fn with implicit cast" {
123 assert(getFirstByte(u8, []u8 {13}) == 13);
124 assert(getFirstByte(u16, []u16 {
123 assert(getFirstByte(u8, []u8{13}) == 13);
124 assert(getFirstByte(u16, []u16{
125125 0,
126126 13,
127127 }) == 0);
......@@ -133,7 +133,7 @@ fn getFirstByte(comptime T: type, mem: []const T) u8 {
133133 return getByte(@ptrCast(&const u8, &mem[0]));
134134}
135135
136const foos = []fn(var) bool {
136const foos = []fn(var) bool{
137137 foo1,
138138 foo2,
139139};
test/cases/incomplete_struct_param_tld.zig+3-5
......@@ -21,11 +21,9 @@ fn foo(a: &const A) i32 {
2121}
2222
2323test "incomplete struct param top level declaration" {
24 const a = A {
25 .b = B {
26 .c = C {
27 .x = 13,
28 },
24 const a = A{
25 .b = B{
26 .c = C{ .x = 13 },
2927 },
3028 };
3129 assert(foo(a) == 13);
test/cases/math.zig+1-1
......@@ -197,7 +197,7 @@ fn test_u64_div() void {
197197 assert(result.remainder == 100663296);
198198}
199199fn divWithResult(a: u64, b: u64) DivResult {
200 return DivResult {
200 return DivResult{
201201 .quotient = a / b,
202202 .remainder = a % b,
203203 };
test/cases/misc.zig+16-26
......@@ -232,7 +232,7 @@ test "string escapes" {
232232}
233233
234234test "multiline string" {
235 const s1 =
235 const s1 =
236236 \\one
237237 \\two)
238238 \\three
......@@ -242,7 +242,7 @@ test "multiline string" {
242242}
243243
244244test "multiline C string" {
245 const s1 =
245 const s1 =
246246 c\\one
247247 c\\two)
248248 c\\three
......@@ -350,15 +350,13 @@ const Test3Point = struct {
350350 x: i32,
351351 y: i32,
352352};
353const test3_foo = Test3Foo {
354 .Three = Test3Point {
353const test3_foo = Test3Foo{
354 .Three = Test3Point{
355355 .x = 3,
356356 .y = 4,
357357 },
358358};
359const test3_bar = Test3Foo {
360 .Two = 13,
361};
359const test3_bar = Test3Foo{ .Two = 13 };
362360fn test3_1(f: &const Test3Foo) void {
363361 switch (f.*) {
364362 Test3Foo.Three => |pt| {
......@@ -417,7 +415,7 @@ test "C string concatenation" {
417415
418416test "cast slice to u8 slice" {
419417 assert(@sizeOf(i32) == 4);
420 var big_thing_array = []i32 {
418 var big_thing_array = []i32{
421419 1,
422420 2,
423421 3,
......@@ -458,9 +456,9 @@ test "non const ptr to aliased type" {
458456}
459457
460458test "array 2D const double ptr" {
461 const rect_2d_vertexes = [][1]f32 {
462 []f32 {1.0},
463 []f32 {2.0},
459 const rect_2d_vertexes = [][1]f32{
460 []f32{1.0},
461 []f32{2.0},
464462 };
465463 testArray2DConstDoublePtr(&rect_2d_vertexes[0][0]);
466464}
......@@ -565,7 +563,7 @@ test "volatile load and store" {
565563test "slice string literal has type []const u8" {
566564 comptime {
567565 assert(@typeOf("aoeu"[0..]) == []const u8);
568 const array = []i32 {
566 const array = []i32{
569567 1,
570568 2,
571569 3,
......@@ -581,13 +579,9 @@ test "global variable initialized to global variable array element" {
581579const GDTEntry = struct {
582580 field: i32,
583581};
584var gdt = []GDTEntry {
585 GDTEntry {
586 .field = 1,
587 },
588 GDTEntry {
589 .field = 2,
590 },
582var gdt = []GDTEntry{
583 GDTEntry{ .field = 1 },
584 GDTEntry{ .field = 2 },
591585};
592586var global_ptr = &gdt[0];
593587
......@@ -648,9 +642,7 @@ fn testStructInFn() void {
648642 kind: BlockKind,
649643 };
650644
651 var block = Block {
652 .kind = 1234,
653 };
645 var block = Block{ .kind = 1234 };
654646
655647 block.kind += 1;
656648
......@@ -694,12 +686,10 @@ const PackedEnum = packed enum {
694686};
695687
696688test "packed struct, enum, union parameters in extern function" {
697 testPackedStuff(PackedStruct {
689 testPackedStuff(PackedStruct{
698690 .a = 1,
699691 .b = 2,
700 }, PackedUnion {
701 .a = 1,
702 }, PackedEnum.A);
692 }, PackedUnion{ .a = 1 }, PackedEnum.A);
703693}
704694
705695export fn testPackedStuff(a: &const PackedStruct, b: &const PackedUnion, c: PackedEnum) void {}
test/cases/null.zig+2-4
......@@ -58,7 +58,7 @@ fn foo(x: ?i32) ?bool {
5858}
5959
6060test "if var maybe pointer" {
61 assert(shouldBeAPlus1(Particle {
61 assert(shouldBeAPlus1(Particle{
6262 .a = 14,
6363 .b = 1,
6464 .c = 1,
......@@ -92,9 +92,7 @@ test "null literal outside function" {
9292const SillyStruct = struct {
9393 context: ?i32,
9494};
95const here_is_a_null_literal = SillyStruct {
96 .context = null,
97};
95const here_is_a_null_literal = SillyStruct{ .context = null };
9896
9997test "test null runtime" {
10098 testTestNullRuntime(null);
test/cases/reflection.zig+1-1
......@@ -59,7 +59,7 @@ test "reflection: enum member types and names" {
5959}
6060
6161test "reflection: @field" {
62 var f = Foo {
62 var f = Foo{
6363 .one = 42,
6464 .two = true,
6565 .three = void{},
test/cases/slice.zig+1-1
......@@ -18,7 +18,7 @@ test "slice child property" {
1818}
1919
2020test "runtime safety lets us slice from len..len" {
21 var an_array = []u8 {
21 var an_array = []u8{
2222 1,
2323 2,
2424 3,
test/cases/struct.zig+15-25
......@@ -27,7 +27,7 @@ test "invake static method in global scope" {
2727}
2828
2929test "void struct fields" {
30 const foo = VoidStructFieldsFoo {
30 const foo = VoidStructFieldsFoo{
3131 .a = void{},
3232 .b = 1,
3333 .c = void{},
......@@ -96,16 +96,12 @@ test "struct byval assign" {
9696}
9797
9898fn structInitializer() void {
99 const val = Val {
100 .x = 42,
101 };
99 const val = Val{ .x = 42 };
102100 assert(val.x == 42);
103101}
104102
105103test "fn call of struct field" {
106 assert(callStructField(Foo {
107 .ptr = aFunc,
108 }) == 13);
104 assert(callStructField(Foo{ .ptr = aFunc }) == 13);
109105}
110106
111107const Foo = struct {
......@@ -121,9 +117,7 @@ fn callStructField(foo: &const Foo) i32 {
121117}
122118
123119test "store member function in variable" {
124 const instance = MemberFnTestFoo {
125 .x = 1234,
126 };
120 const instance = MemberFnTestFoo{ .x = 1234 };
127121 const memberFn = MemberFnTestFoo.member;
128122 const result = memberFn(instance);
129123 assert(result == 1234);
......@@ -136,17 +130,13 @@ const MemberFnTestFoo = struct {
136130};
137131
138132test "call member function directly" {
139 const instance = MemberFnTestFoo {
140 .x = 1234,
141 };
133 const instance = MemberFnTestFoo{ .x = 1234 };
142134 const result = MemberFnTestFoo.member(instance);
143135 assert(result == 1234);
144136}
145137
146138test "member functions" {
147 const r = MemberFnRand {
148 .seed = 1234,
149 };
139 const r = MemberFnRand{ .seed = 1234 };
150140 assert(r.getSeed() == 1234);
151141}
152142const MemberFnRand = struct {
......@@ -165,7 +155,7 @@ const Bar = struct {
165155 y: i32,
166156};
167157fn makeBar(x: i32, y: i32) Bar {
168 return Bar {
158 return Bar{
169159 .x = x,
170160 .y = y,
171161 };
......@@ -190,7 +180,7 @@ fn testReturnEmptyStructFromFn() EmptyStruct2 {
190180}
191181
192182test "pass slice of empty struct to fn" {
193 assert(testPassSliceOfEmptyStructToFn([]EmptyStruct2 {EmptyStruct2{}}) == 1);
183 assert(testPassSliceOfEmptyStructToFn([]EmptyStruct2{EmptyStruct2{}}) == 1);
194184}
195185fn testPassSliceOfEmptyStructToFn(slice: []const EmptyStruct2) usize {
196186 return slice.len;
......@@ -202,7 +192,7 @@ const APackedStruct = packed struct {
202192};
203193
204194test "packed struct" {
205 var foo = APackedStruct {
195 var foo = APackedStruct{
206196 .x = 1,
207197 .y = 2,
208198 };
......@@ -217,7 +207,7 @@ const BitField1 = packed struct {
217207 c: u2,
218208};
219209
220const bit_field_1 = BitField1 {
210const bit_field_1 = BitField1{
221211 .a = 1,
222212 .b = 2,
223213 .c = 3,
......@@ -267,7 +257,7 @@ test "packed struct 24bits" {
267257 assert(@sizeOf(Foo96Bits) == 12);
268258 }
269259
270 var value = Foo96Bits {
260 var value = Foo96Bits{
271261 .a = 0,
272262 .b = 0,
273263 .c = 0,
......@@ -310,7 +300,7 @@ test "packed array 24bits" {
310300 assert(@sizeOf(FooArray24Bits) == 2 + 2 * 3 + 2);
311301 }
312302
313 var bytes = []u8 {0} ** (@sizeOf(FooArray24Bits) + 1);
303 var bytes = []u8{0} ** (@sizeOf(FooArray24Bits) + 1);
314304 bytes[bytes.len - 1] = 0xaa;
315305 const ptr = &([]FooArray24Bits)(bytes[0..bytes.len - 1])[0];
316306 assert(ptr.a == 0);
......@@ -360,7 +350,7 @@ test "aligned array of packed struct" {
360350 assert(@sizeOf(FooArrayOfAligned) == 2 * 2);
361351 }
362352
363 var bytes = []u8 {0xbb} ** @sizeOf(FooArrayOfAligned);
353 var bytes = []u8{0xbb} ** @sizeOf(FooArrayOfAligned);
364354 const ptr = &([]FooArrayOfAligned)(bytes[0..bytes.len])[0];
365355
366356 assert(ptr.a[0].a == 0xbb);
......@@ -370,11 +360,11 @@ test "aligned array of packed struct" {
370360}
371361
372362test "runtime struct initialization of bitfield" {
373 const s1 = Nibbles {
363 const s1 = Nibbles{
374364 .x = x1,
375365 .y = x1,
376366 };
377 const s2 = Nibbles {
367 const s2 = Nibbles{
378368 .x = u4(x2),
379369 .y = u4(x2),
380370 };
test/cases/struct_contains_slice_of_itself.zig+8-8
......@@ -6,31 +6,31 @@ const Node = struct {
66};
77
88test "struct contains slice of itself" {
9 var other_nodes = []Node {
10 Node {
9 var other_nodes = []Node{
10 Node{
1111 .payload = 31,
1212 .children = []Node{},
1313 },
14 Node {
14 Node{
1515 .payload = 32,
1616 .children = []Node{},
1717 },
1818 };
19 var nodes = []Node {
20 Node {
19 var nodes = []Node{
20 Node{
2121 .payload = 1,
2222 .children = []Node{},
2323 },
24 Node {
24 Node{
2525 .payload = 2,
2626 .children = []Node{},
2727 },
28 Node {
28 Node{
2929 .payload = 3,
3030 .children = other_nodes[0..],
3131 },
3232 };
33 const root = Node {
33 const root = Node{
3434 .payload = 1234,
3535 .children = nodes[0..],
3636 };
test/cases/switch.zig+17-37
......@@ -6,10 +6,7 @@ test "switch with numbers" {
66
77fn testSwitchWithNumbers(x: u32) void {
88 const result = switch (x) {
9 1,
10 2,
11 3,
12 4 ... 8 => false,
9 1, 2, 3, 4...8 => false,
1310 13 => true,
1411 else => false,
1512 };
......@@ -25,9 +22,9 @@ test "switch with all ranges" {
2522
2623fn testSwitchWithAllRanges(x: u32, y: u32) u32 {
2724 return switch (x) {
28 0 ... 100 => 1,
29 101 ... 200 => 2,
30 201 ... 300 => 3,
25 0...100 => 1,
26 101...200 => 2,
27 201...300 => 3,
3128 else => y,
3229 };
3330}
......@@ -37,10 +34,8 @@ test "implicit comptime switch" {
3734 const result = switch (x) {
3835 3 => 10,
3936 4 => 11,
40 5,
41 6 => 12,
42 7,
43 8 => 13,
37 5, 6 => 12,
38 7, 8 => 13,
4439 else => 14,
4540 };
4641
......@@ -86,15 +81,9 @@ const SwitchStatmentFoo = enum {
8681};
8782
8883test "switch prong with variable" {
89 switchProngWithVarFn(SwitchProngWithVarEnum {
90 .One = 13,
91 });
92 switchProngWithVarFn(SwitchProngWithVarEnum {
93 .Two = 13.0,
94 });
95 switchProngWithVarFn(SwitchProngWithVarEnum {
96 .Meh = {},
97 });
84 switchProngWithVarFn(SwitchProngWithVarEnum{ .One = 13 });
85 switchProngWithVarFn(SwitchProngWithVarEnum{ .Two = 13.0 });
86 switchProngWithVarFn(SwitchProngWithVarEnum{ .Meh = {} });
9887}
9988const SwitchProngWithVarEnum = union(enum) {
10089 One: i32,
......@@ -121,9 +110,7 @@ test "switch on enum using pointer capture" {
121110}
122111
123112fn testSwitchEnumPtrCapture() void {
124 var value = SwitchProngWithVarEnum {
125 .One = 1234,
126 };
113 var value = SwitchProngWithVarEnum{ .One = 1234 };
127114 switch (value) {
128115 SwitchProngWithVarEnum.One => |*x| x.* += 1,
129116 else => unreachable,
......@@ -136,12 +123,8 @@ fn testSwitchEnumPtrCapture() void {
136123
137124test "switch with multiple expressions" {
138125 const x = switch (returnsFive()) {
139 1,
140 2,
141 3 => 1,
142 4,
143 5,
144 6 => 2,
126 1, 2, 3 => 1,
127 4, 5, 6 => 2,
145128 else => i32(3),
146129 };
147130 assert(x == 2);
......@@ -156,9 +139,7 @@ const Number = union(enum) {
156139 Three: f32,
157140};
158141
159const number = Number {
160 .Three = 1.23,
161};
142const number = Number{ .Three = 1.23 };
162143
163144fn returnsFalse() bool {
164145 switch (number) {
......@@ -212,12 +193,11 @@ fn testSwitchHandleAllCasesExhaustive(x: u2) u2 {
212193
213194fn testSwitchHandleAllCasesRange(x: u8) u8 {
214195 return switch (x) {
215 0 ... 100 => u8(0),
216 101 ... 200 => 1,
217 201,
218 203 => 2,
196 0...100 => u8(0),
197 101...200 => 1,
198 201, 203 => 2,
219199 202 => 4,
220 204 ... 255 => 3,
200 204...255 => 3,
221201 };
222202}
223203
test/cases/switch_prong_err_enum.zig+1-3
......@@ -14,9 +14,7 @@ const FormValue = union(enum) {
1414
1515fn doThing(form_id: u64) error!FormValue {
1616 return switch (form_id) {
17 17 => FormValue {
18 .Address = try readOnce(),
19 },
17 17 => FormValue{ .Address = try readOnce() },
2018 else => error.InvalidDebugInfo,
2119 };
2220}
test/cases/switch_prong_implicit_cast.zig+2-6
......@@ -7,12 +7,8 @@ const FormValue = union(enum) {
77
88fn foo(id: u64) !FormValue {
99 return switch (id) {
10 2 => FormValue {
11 .Two = true,
12 },
13 1 => FormValue {
14 .One = {},
15 },
10 2 => FormValue{ .Two = true },
11 1 => FormValue{ .One = {} },
1612 else => return error.Whatever,
1713 };
1814}
test/cases/this.zig+1-1
......@@ -29,7 +29,7 @@ test "this refer to module call private fn" {
2929}
3030
3131test "this refer to container" {
32 var pt = Point(i32) {
32 var pt = Point(i32){
3333 .x = 12,
3434 .y = 34,
3535 };
test/cases/try.zig+1-2
......@@ -7,8 +7,7 @@ test "try on error union" {
77
88fn tryOnErrorUnionImpl() void {
99 const x = if (returnsTen()) |val| val + 1 else |err| switch (err) {
10 error.ItBroke,
11 error.NoMem => 1,
10 error.ItBroke, error.NoMem => 1,
1211 error.CrappedOut => i32(2),
1312 else => unreachable,
1413 };
test/cases/type_info.zig+2-2
......@@ -103,7 +103,7 @@ test "type info: error set, error union info" {
103103}
104104
105105fn testErrorSet() void {
106 const TestErrorSet = error {
106 const TestErrorSet = error{
107107 First,
108108 Second,
109109 Third,
......@@ -196,7 +196,7 @@ fn testStruct() void {
196196 assert(!struct_info.Struct.defs[0].data.Fn.is_extern);
197197 assert(struct_info.Struct.defs[0].data.Fn.lib_name == null);
198198 assert(struct_info.Struct.defs[0].data.Fn.return_type == void);
199 assert(struct_info.Struct.defs[0].data.Fn.fn_type == fn(&const TestStruct)void);
199 assert(struct_info.Struct.defs[0].data.Fn.fn_type == fn(&const TestStruct) void);
200200}
201201
202202const TestStruct = packed struct {
test/cases/union.zig+2-3
......@@ -50,10 +50,10 @@ test "basic unions" {
5050
5151test "comptime union field access" {
5252 comptime {
53 var foo = Foo { .int = 0 };
53 var foo = Foo{ .int = 0 };
5454 assert(foo.int == 0);
5555
56 foo = Foo { .float = 42.42 };
56 foo = Foo{ .float = 42.42 };
5757 assert(foo.float == 42.42);
5858 }
5959}
......@@ -286,7 +286,6 @@ const PartialInstWithPayload = union(enum) {
286286 Compiled: i32,
287287};
288288
289
290289test "access a member of tagged union with conflicting enum tag name" {
291290 const Bar = union(enum) {
292291 A: A,
test/cases/var_args.zig+1-1
......@@ -58,7 +58,7 @@ fn extraFn(extra: u32, args: ...) usize {
5858 return args.len;
5959}
6060
61const foos = []fn(...) bool {
61const foos = []fn(...) bool{
6262 foo1,
6363 foo2,
6464};
test/cases/void.zig+1-1
......@@ -8,7 +8,7 @@ const Foo = struct {
88
99test "compare void with void compile time known" {
1010 comptime {
11 const foo = Foo {
11 const foo = Foo{
1212 .a = {},
1313 .b = 1,
1414 .c = {},
test/cases/while.zig+2-2
......@@ -151,7 +151,7 @@ test "while on nullable with else result follow break prong" {
151151test "while on error union with else result follow else prong" {
152152 const result = while (returnError()) |value| {
153153 break value;
154 } else|err|
154 } else |err|
155155 i32(2);
156156 assert(result == 2);
157157}
......@@ -159,7 +159,7 @@ test "while on error union with else result follow else prong" {
159159test "while on error union with else result follow break prong" {
160160 const result = while (returnSuccess(10)) |value| {
161161 break value;
162 } else|err|
162 } else |err|
163163 i32(2);
164164 assert(result == 10);
165165}
test/compare_output.zig+2-2
......@@ -475,7 +475,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
475475 \\
476476 );
477477
478 tc.setCommandLineArgs([][]const u8 {
478 tc.setCommandLineArgs([][]const u8{
479479 "first arg",
480480 "'a' 'b' \\",
481481 "bare",
......@@ -516,7 +516,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
516516 \\
517517 );
518518
519 tc.setCommandLineArgs([][]const u8 {
519 tc.setCommandLineArgs([][]const u8{
520520 "first arg",
521521 "'a' 'b' \\",
522522 "bare",
test/compile_errors.zig+1502-718
......@@ -1,7 +1,8 @@
11const tests = @import("tests.zig");
22
33pub fn addCases(cases: &tests.CompileErrorContext) void {
4 cases.add("invalid deref on switch target",
4 cases.add(
5 "invalid deref on switch target",
56 \\comptime {
67 \\ var tile = Tile.Empty;
78 \\ switch (tile.*) {
......@@ -14,15 +15,19 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
1415 \\ Filled,
1516 \\};
1617 ,
17 ".tmp_source.zig:3:17: error: invalid deref on switch target");
18 ".tmp_source.zig:3:17: error: invalid deref on switch target",
19 );
1820
19 cases.add("invalid field access in comptime",
21 cases.add(
22 "invalid field access in comptime",
2023 \\comptime { var x = doesnt_exist.whatever; }
2124 ,
22 ".tmp_source.zig:1:20: error: use of undeclared identifier 'doesnt_exist'");
25 ".tmp_source.zig:1:20: error: use of undeclared identifier 'doesnt_exist'",
26 );
2327
24 cases.add("suspend inside suspend block",
25 \\const std = @import("std");
28 cases.add(
29 "suspend inside suspend block",
30 \\const std = @import("std",);
2631 \\
2732 \\export fn entry() void {
2833 \\ var buf: [500]u8 = undefined;
......@@ -39,27 +44,32 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
3944 \\}
4045 ,
4146 ".tmp_source.zig:12:9: error: cannot suspend inside suspend block",
42 ".tmp_source.zig:11:5: note: other suspend block here");
47 ".tmp_source.zig:11:5: note: other suspend block here",
48 );
4349
44 cases.add("assign inline fn to non-comptime var",
50 cases.add(
51 "assign inline fn to non-comptime var",
4552 \\export fn entry() void {
4653 \\ var a = b;
4754 \\}
4855 \\inline fn b() void { }
4956 ,
5057 ".tmp_source.zig:2:5: error: functions marked inline must be stored in const or comptime var",
51 ".tmp_source.zig:4:8: note: declared here");
58 ".tmp_source.zig:4:8: note: declared here",
59 );
5260
53 cases.add("wrong type passed to @panic",
61 cases.add(
62 "wrong type passed to @panic",
5463 \\export fn entry() void {
5564 \\ var e = error.Foo;
5665 \\ @panic(e);
5766 \\}
5867 ,
59 ".tmp_source.zig:3:12: error: expected type '[]const u8', found 'error{Foo}'");
68 ".tmp_source.zig:3:12: error: expected type '[]const u8', found 'error{Foo}'",
69 );
6070
61
62 cases.add("@tagName used on union with no associated enum tag",
71 cases.add(
72 "@tagName used on union with no associated enum tag",
6373 \\const FloatInt = extern union {
6474 \\ Float: f32,
6575 \\ Int: i32,
......@@ -70,10 +80,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
7080 \\}
7181 ,
7282 ".tmp_source.zig:7:19: error: union has no associated enum",
73 ".tmp_source.zig:1:18: note: declared here");
83 ".tmp_source.zig:1:18: note: declared here",
84 );
7485
75 cases.add("returning error from void async function",
76 \\const std = @import("std");
86 cases.add(
87 "returning error from void async function",
88 \\const std = @import("std",);
7789 \\export fn entry() void {
7890 \\ const p = async<std.debug.global_allocator> amain() catch unreachable;
7991 \\}
......@@ -81,31 +93,39 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
8193 \\ return error.ShouldBeCompileError;
8294 \\}
8395 ,
84 ".tmp_source.zig:6:17: error: expected type 'void', found 'error{ShouldBeCompileError}'");
96 ".tmp_source.zig:6:17: error: expected type 'void', found 'error{ShouldBeCompileError}'",
97 );
8598
86 cases.add("var not allowed in structs",
99 cases.add(
100 "var not allowed in structs",
87101 \\export fn entry() void {
88102 \\ var s = (struct{v: var}){.v=i32(10)};
89103 \\}
90104 ,
91 ".tmp_source.zig:2:23: error: invalid token: 'var'");
105 ".tmp_source.zig:2:23: error: invalid token: 'var'",
106 );
92107
93 cases.add("@ptrCast discards const qualifier",
108 cases.add(
109 "@ptrCast discards const qualifier",
94110 \\export fn entry() void {
95111 \\ const x: i32 = 1234;
96112 \\ const y = @ptrCast(&i32, &x);
97113 \\}
98114 ,
99 ".tmp_source.zig:3:15: error: cast discards const qualifier");
115 ".tmp_source.zig:3:15: error: cast discards const qualifier",
116 );
100117
101 cases.add("comptime slice of undefined pointer non-zero len",
118 cases.add(
119 "comptime slice of undefined pointer non-zero len",
102120 \\export fn entry() void {
103121 \\ const slice = (&i32)(undefined)[0..1];
104122 \\}
105123 ,
106 ".tmp_source.zig:2:36: error: non-zero length slice of undefined pointer");
124 ".tmp_source.zig:2:36: error: non-zero length slice of undefined pointer",
125 );
107126
108 cases.add("type checking function pointers",
127 cases.add(
128 "type checking function pointers",
109129 \\fn a(b: fn (&const u8) void) void {
110130 \\ b('a');
111131 \\}
......@@ -116,9 +136,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
116136 \\ a(c);
117137 \\}
118138 ,
119 ".tmp_source.zig:8:7: error: expected type 'fn(&const u8) void', found 'fn(u8) void'");
139 ".tmp_source.zig:8:7: error: expected type 'fn(&const u8) void', found 'fn(u8) void'",
140 );
120141
121 cases.add("no else prong on switch on global error set",
142 cases.add(
143 "no else prong on switch on global error set",
122144 \\export fn entry() void {
123145 \\ foo(error.A);
124146 \\}
......@@ -128,18 +150,22 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
128150 \\ }
129151 \\}
130152 ,
131 ".tmp_source.zig:5:5: error: else prong required when switching on type 'error'");
153 ".tmp_source.zig:5:5: error: else prong required when switching on type 'error'",
154 );
132155
133 cases.add("inferred error set with no returned error",
156 cases.add(
157 "inferred error set with no returned error",
134158 \\export fn entry() void {
135159 \\ foo() catch unreachable;
136160 \\}
137161 \\fn foo() !void {
138162 \\}
139163 ,
140 ".tmp_source.zig:4:11: error: function with inferred error set must return at least one possible error");
164 ".tmp_source.zig:4:11: error: function with inferred error set must return at least one possible error",
165 );
141166
142 cases.add("error not handled in switch",
167 cases.add(
168 "error not handled in switch",
143169 \\export fn entry() void {
144170 \\ foo(452) catch |err| switch (err) {
145171 \\ error.Foo => {},
......@@ -155,9 +181,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
155181 \\}
156182 ,
157183 ".tmp_source.zig:2:26: error: error.Baz not handled in switch",
158 ".tmp_source.zig:2:26: error: error.Bar not handled in switch");
184 ".tmp_source.zig:2:26: error: error.Bar not handled in switch",
185 );
159186
160 cases.add("duplicate error in switch",
187 cases.add(
188 "duplicate error in switch",
161189 \\export fn entry() void {
162190 \\ foo(452) catch |err| switch (err) {
163191 \\ error.Foo => {},
......@@ -175,9 +203,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
175203 \\}
176204 ,
177205 ".tmp_source.zig:5:14: error: duplicate switch value: '@typeOf(foo).ReturnType.ErrorSet.Foo'",
178 ".tmp_source.zig:3:14: note: other value is here");
206 ".tmp_source.zig:3:14: note: other value is here",
207 );
179208
180 cases.add("range operator in switch used on error set",
209 cases.add(
210 "range operator in switch used on error set",
181211 \\export fn entry() void {
182212 \\ try foo(452) catch |err| switch (err) {
183213 \\ error.A ... error.B => {},
......@@ -192,31 +222,39 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
192222 \\ }
193223 \\}
194224 ,
195 ".tmp_source.zig:3:17: error: operator not allowed for errors");
225 ".tmp_source.zig:3:17: error: operator not allowed for errors",
226 );
196227
197 cases.add("inferring error set of function pointer",
228 cases.add(
229 "inferring error set of function pointer",
198230 \\comptime {
199231 \\ const z: ?fn()!void = null;
200232 \\}
201233 ,
202 ".tmp_source.zig:2:15: error: inferring error set of return type valid only for function definitions");
234 ".tmp_source.zig:2:15: error: inferring error set of return type valid only for function definitions",
235 );
203236
204 cases.add("access non-existent member of error set",
237 cases.add(
238 "access non-existent member of error set",
205239 \\const Foo = error{A};
206240 \\comptime {
207241 \\ const z = Foo.Bar;
208242 \\}
209243 ,
210 ".tmp_source.zig:3:18: error: no error named 'Bar' in 'Foo'");
244 ".tmp_source.zig:3:18: error: no error named 'Bar' in 'Foo'",
245 );
211246
212 cases.add("error union operator with non error set LHS",
247 cases.add(
248 "error union operator with non error set LHS",
213249 \\comptime {
214250 \\ const z = i32!i32;
215251 \\}
216252 ,
217 ".tmp_source.zig:2:15: error: expected error set type, found type 'i32'");
253 ".tmp_source.zig:2:15: error: expected error set type, found type 'i32'",
254 );
218255
219 cases.add("error equality but sets have no common members",
256 cases.add(
257 "error equality but sets have no common members",
220258 \\const Set1 = error{A, C};
221259 \\const Set2 = error{B, D};
222260 \\export fn entry() void {
......@@ -228,16 +266,20 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
228266 \\ }
229267 \\}
230268 ,
231 ".tmp_source.zig:7:11: error: error sets 'Set1' and 'Set2' have no common errors");
269 ".tmp_source.zig:7:11: error: error sets 'Set1' and 'Set2' have no common errors",
270 );
232271
233 cases.add("only equality binary operator allowed for error sets",
272 cases.add(
273 "only equality binary operator allowed for error sets",
234274 \\comptime {
235275 \\ const z = error.A > error.B;
236276 \\}
237277 ,
238 ".tmp_source.zig:2:23: error: operator not allowed for errors");
278 ".tmp_source.zig:2:23: error: operator not allowed for errors",
279 );
239280
240 cases.add("explicit error set cast known at comptime violates error sets",
281 cases.add(
282 "explicit error set cast known at comptime violates error sets",
241283 \\const Set1 = error {A, B};
242284 \\const Set2 = error {A, C};
243285 \\comptime {
......@@ -245,9 +287,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
245287 \\ var y = Set2(x);
246288 \\}
247289 ,
248 ".tmp_source.zig:5:17: error: error.B not a member of error set 'Set2'");
290 ".tmp_source.zig:5:17: error: error.B not a member of error set 'Set2'",
291 );
249292
250 cases.add("cast error union of global error set to error union of smaller error set",
293 cases.add(
294 "cast error union of global error set to error union of smaller error set",
251295 \\const SmallErrorSet = error{A};
252296 \\export fn entry() void {
253297 \\ var x: SmallErrorSet!i32 = foo();
......@@ -257,9 +301,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
257301 \\}
258302 ,
259303 ".tmp_source.zig:3:35: error: expected 'SmallErrorSet!i32', found 'error!i32'",
260 ".tmp_source.zig:3:35: note: unable to cast global error set into smaller set");
304 ".tmp_source.zig:3:35: note: unable to cast global error set into smaller set",
305 );
261306
262 cases.add("cast global error set to error set",
307 cases.add(
308 "cast global error set to error set",
263309 \\const SmallErrorSet = error{A};
264310 \\export fn entry() void {
265311 \\ var x: SmallErrorSet = foo();
......@@ -269,9 +315,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
269315 \\}
270316 ,
271317 ".tmp_source.zig:3:31: error: expected 'SmallErrorSet', found 'error'",
272 ".tmp_source.zig:3:31: note: unable to cast global error set into smaller set");
318 ".tmp_source.zig:3:31: note: unable to cast global error set into smaller set",
319 );
273320
274 cases.add("recursive inferred error set",
321 cases.add(
322 "recursive inferred error set",
275323 \\export fn entry() void {
276324 \\ foo() catch unreachable;
277325 \\}
......@@ -279,9 +327,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
279327 \\ try foo();
280328 \\}
281329 ,
282 ".tmp_source.zig:5:5: error: cannot resolve inferred error set '@typeOf(foo).ReturnType.ErrorSet': function 'foo' not fully analyzed yet");
330 ".tmp_source.zig:5:5: error: cannot resolve inferred error set '@typeOf(foo).ReturnType.ErrorSet': function 'foo' not fully analyzed yet",
331 );
283332
284 cases.add("implicit cast of error set not a subset",
333 cases.add(
334 "implicit cast of error set not a subset",
285335 \\const Set1 = error{A, B};
286336 \\const Set2 = error{A, C};
287337 \\export fn entry() void {
......@@ -292,18 +342,22 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
292342 \\}
293343 ,
294344 ".tmp_source.zig:7:19: error: expected 'Set2', found 'Set1'",
295 ".tmp_source.zig:1:23: note: 'error.B' not a member of destination error set");
345 ".tmp_source.zig:1:23: note: 'error.B' not a member of destination error set",
346 );
296347
297 cases.add("int to err global invalid number",
348 cases.add(
349 "int to err global invalid number",
298350 \\const Set1 = error{A, B};
299351 \\comptime {
300352 \\ var x: usize = 3;
301353 \\ var y = error(x);
302354 \\}
303355 ,
304 ".tmp_source.zig:4:18: error: integer value 3 represents no error");
356 ".tmp_source.zig:4:18: error: integer value 3 represents no error",
357 );
305358
306 cases.add("int to err non global invalid number",
359 cases.add(
360 "int to err non global invalid number",
307361 \\const Set1 = error{A, B};
308362 \\const Set2 = error{A, C};
309363 \\comptime {
......@@ -311,16 +365,20 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
311365 \\ var y = Set2(x);
312366 \\}
313367 ,
314 ".tmp_source.zig:5:17: error: integer value 2 represents no error in 'Set2'");
368 ".tmp_source.zig:5:17: error: integer value 2 represents no error in 'Set2'",
369 );
315370
316 cases.add("@memberCount of error",
371 cases.add(
372 "@memberCount of error",
317373 \\comptime {
318374 \\ _ = @memberCount(error);
319375 \\}
320376 ,
321 ".tmp_source.zig:2:9: error: global error set member count not available at comptime");
377 ".tmp_source.zig:2:9: error: global error set member count not available at comptime",
378 );
322379
323 cases.add("duplicate error value in error set",
380 cases.add(
381 "duplicate error value in error set",
324382 \\const Foo = error {
325383 \\ Bar,
326384 \\ Bar,
......@@ -330,22 +388,30 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
330388 \\}
331389 ,
332390 ".tmp_source.zig:3:5: error: duplicate error: 'Bar'",
333 ".tmp_source.zig:2:5: note: other error here");
391 ".tmp_source.zig:2:5: note: other error here",
392 );
334393
335 cases.add("cast negative integer literal to usize",
394 cases.add(
395 "cast negative integer literal to usize",
336396 \\export fn entry() void {
337397 \\ const x = usize(-10);
338398 \\}
339 , ".tmp_source.zig:2:21: error: cannot cast negative value -10 to unsigned integer type 'usize'");
399 ,
400 ".tmp_source.zig:2:21: error: cannot cast negative value -10 to unsigned integer type 'usize'",
401 );
340402
341 cases.add("use invalid number literal as array index",
403 cases.add(
404 "use invalid number literal as array index",
342405 \\var v = 25;
343406 \\export fn entry() void {
344407 \\ var arr: [v]u8 = undefined;
345408 \\}
346 , ".tmp_source.zig:1:1: error: unable to infer variable type");
409 ,
410 ".tmp_source.zig:1:1: error: unable to infer variable type",
411 );
347412
348 cases.add("duplicate struct field",
413 cases.add(
414 "duplicate struct field",
349415 \\const Foo = struct {
350416 \\ Bar: i32,
351417 \\ Bar: usize,
......@@ -355,9 +421,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
355421 \\}
356422 ,
357423 ".tmp_source.zig:3:5: error: duplicate struct field: 'Bar'",
358 ".tmp_source.zig:2:5: note: other field here");
424 ".tmp_source.zig:2:5: note: other field here",
425 );
359426
360 cases.add("duplicate union field",
427 cases.add(
428 "duplicate union field",
361429 \\const Foo = union {
362430 \\ Bar: i32,
363431 \\ Bar: usize,
......@@ -367,9 +435,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
367435 \\}
368436 ,
369437 ".tmp_source.zig:3:5: error: duplicate union field: 'Bar'",
370 ".tmp_source.zig:2:5: note: other field here");
438 ".tmp_source.zig:2:5: note: other field here",
439 );
371440
372 cases.add("duplicate enum field",
441 cases.add(
442 "duplicate enum field",
373443 \\const Foo = enum {
374444 \\ Bar,
375445 \\ Bar,
......@@ -380,77 +450,108 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
380450 \\}
381451 ,
382452 ".tmp_source.zig:3:5: error: duplicate enum field: 'Bar'",
383 ".tmp_source.zig:2:5: note: other field here");
453 ".tmp_source.zig:2:5: note: other field here",
454 );
384455
385 cases.add("calling function with naked calling convention",
456 cases.add(
457 "calling function with naked calling convention",
386458 \\export fn entry() void {
387459 \\ foo();
388460 \\}
389461 \\nakedcc fn foo() void { }
390462 ,
391463 ".tmp_source.zig:2:5: error: unable to call function with naked calling convention",
392 ".tmp_source.zig:4:9: note: declared here");
464 ".tmp_source.zig:4:9: note: declared here",
465 );
393466
394 cases.add("function with invalid return type",
467 cases.add(
468 "function with invalid return type",
395469 \\export fn foo() boid {}
396 , ".tmp_source.zig:1:17: error: use of undeclared identifier 'boid'");
470 ,
471 ".tmp_source.zig:1:17: error: use of undeclared identifier 'boid'",
472 );
397473
398 cases.add("function with non-extern non-packed enum parameter",
474 cases.add(
475 "function with non-extern non-packed enum parameter",
399476 \\const Foo = enum { A, B, C };
400477 \\export fn entry(foo: Foo) void { }
401 , ".tmp_source.zig:2:22: error: parameter of type 'Foo' not allowed in function with calling convention 'ccc'");
478 ,
479 ".tmp_source.zig:2:22: error: parameter of type 'Foo' not allowed in function with calling convention 'ccc'",
480 );
402481
403 cases.add("function with non-extern non-packed struct parameter",
482 cases.add(
483 "function with non-extern non-packed struct parameter",
404484 \\const Foo = struct {
405485 \\ A: i32,
406486 \\ B: f32,
407487 \\ C: bool,
408488 \\};
409489 \\export fn entry(foo: Foo) void { }
410 , ".tmp_source.zig:6:22: error: parameter of type 'Foo' not allowed in function with calling convention 'ccc'");
490 ,
491 ".tmp_source.zig:6:22: error: parameter of type 'Foo' not allowed in function with calling convention 'ccc'",
492 );
411493
412 cases.add("function with non-extern non-packed union parameter",
494 cases.add(
495 "function with non-extern non-packed union parameter",
413496 \\const Foo = union {
414497 \\ A: i32,
415498 \\ B: f32,
416499 \\ C: bool,
417500 \\};
418501 \\export fn entry(foo: Foo) void { }
419 , ".tmp_source.zig:6:22: error: parameter of type 'Foo' not allowed in function with calling convention 'ccc'");
502 ,
503 ".tmp_source.zig:6:22: error: parameter of type 'Foo' not allowed in function with calling convention 'ccc'",
504 );
420505
421 cases.add("switch on enum with 1 field with no prongs",
506 cases.add(
507 "switch on enum with 1 field with no prongs",
422508 \\const Foo = enum { M };
423509 \\
424510 \\export fn entry() void {
425511 \\ var f = Foo.M;
426512 \\ switch (f) {}
427513 \\}
428 , ".tmp_source.zig:5:5: error: enumeration value 'Foo.M' not handled in switch");
514 ,
515 ".tmp_source.zig:5:5: error: enumeration value 'Foo.M' not handled in switch",
516 );
429517
430 cases.add("shift by negative comptime integer",
518 cases.add(
519 "shift by negative comptime integer",
431520 \\comptime {
432521 \\ var a = 1 >> -1;
433522 \\}
434 , ".tmp_source.zig:2:18: error: shift by negative value -1");
523 ,
524 ".tmp_source.zig:2:18: error: shift by negative value -1",
525 );
435526
436 cases.add("@panic called at compile time",
527 cases.add(
528 "@panic called at compile time",
437529 \\export fn entry() void {
438530 \\ comptime {
439 \\ @panic("aoeu");
531 \\ @panic("aoeu",);
440532 \\ }
441533 \\}
442 , ".tmp_source.zig:3:9: error: encountered @panic at compile-time");
534 ,
535 ".tmp_source.zig:3:9: error: encountered @panic at compile-time",
536 );
443537
444 cases.add("wrong return type for main",
538 cases.add(
539 "wrong return type for main",
445540 \\pub fn main() f32 { }
446 , "error: expected return type of main to be 'u8', 'noreturn', 'void', or '!void'");
541 ,
542 "error: expected return type of main to be 'u8', 'noreturn', 'void', or '!void'",
543 );
447544
448 cases.add("double ?? on main return value",
545 cases.add(
546 "double ?? on main return value",
449547 \\pub fn main() ??void {
450548 \\}
451 , "error: expected return type of main to be 'u8', 'noreturn', 'void', or '!void'");
549 ,
550 "error: expected return type of main to be 'u8', 'noreturn', 'void', or '!void'",
551 );
452552
453 cases.add("bad identifier in function with struct defined inside function which references local const",
553 cases.add(
554 "bad identifier in function with struct defined inside function which references local const",
454555 \\export fn entry() void {
455556 \\ const BlockKind = u32;
456557 \\
......@@ -460,9 +561,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
460561 \\
461562 \\ bogus;
462563 \\}
463 , ".tmp_source.zig:8:5: error: use of undeclared identifier 'bogus'");
564 ,
565 ".tmp_source.zig:8:5: error: use of undeclared identifier 'bogus'",
566 );
464567
465 cases.add("labeled break not found",
568 cases.add(
569 "labeled break not found",
466570 \\export fn entry() void {
467571 \\ blah: while (true) {
468572 \\ while (true) {
......@@ -470,9 +574,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
470574 \\ }
471575 \\ }
472576 \\}
473 , ".tmp_source.zig:4:13: error: label not found: 'outer'");
577 ,
578 ".tmp_source.zig:4:13: error: label not found: 'outer'",
579 );
474580
475 cases.add("labeled continue not found",
581 cases.add(
582 "labeled continue not found",
476583 \\export fn entry() void {
477584 \\ var i: usize = 0;
478585 \\ blah: while (i < 10) : (i += 1) {
......@@ -481,9 +588,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
481588 \\ }
482589 \\ }
483590 \\}
484 , ".tmp_source.zig:5:13: error: labeled loop not found: 'outer'");
591 ,
592 ".tmp_source.zig:5:13: error: labeled loop not found: 'outer'",
593 );
485594
486 cases.add("attempt to use 0 bit type in extern fn",
595 cases.add(
596 "attempt to use 0 bit type in extern fn",
487597 \\extern fn foo(ptr: extern fn(&void) void) void;
488598 \\
489599 \\export fn entry() void {
......@@ -491,390 +601,541 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
491601 \\}
492602 \\
493603 \\extern fn bar(x: &void) void { }
494 , ".tmp_source.zig:7:18: error: parameter of type '&void' has 0 bits; not allowed in function with calling convention 'ccc'");
604 ,
605 ".tmp_source.zig:7:18: error: parameter of type '&void' has 0 bits; not allowed in function with calling convention 'ccc'",
606 );
495607
496 cases.add("implicit semicolon - block statement",
608 cases.add(
609 "implicit semicolon - block statement",
497610 \\export fn entry() void {
498611 \\ {}
499612 \\ var good = {};
500613 \\ ({})
501614 \\ var bad = {};
502615 \\}
503 , ".tmp_source.zig:5:5: error: expected token ';', found 'var'");
616 ,
617 ".tmp_source.zig:5:5: error: expected token ';', found 'var'",
618 );
504619
505 cases.add("implicit semicolon - block expr",
620 cases.add(
621 "implicit semicolon - block expr",
506622 \\export fn entry() void {
507623 \\ _ = {};
508624 \\ var good = {};
509625 \\ _ = {}
510626 \\ var bad = {};
511627 \\}
512 , ".tmp_source.zig:5:5: error: expected token ';', found 'var'");
628 ,
629 ".tmp_source.zig:5:5: error: expected token ';', found 'var'",
630 );
513631
514 cases.add("implicit semicolon - comptime statement",
632 cases.add(
633 "implicit semicolon - comptime statement",
515634 \\export fn entry() void {
516635 \\ comptime {}
517636 \\ var good = {};
518637 \\ comptime ({})
519638 \\ var bad = {};
520639 \\}
521 , ".tmp_source.zig:5:5: error: expected token ';', found 'var'");
640 ,
641 ".tmp_source.zig:5:5: error: expected token ';', found 'var'",
642 );
522643
523 cases.add("implicit semicolon - comptime expression",
644 cases.add(
645 "implicit semicolon - comptime expression",
524646 \\export fn entry() void {
525647 \\ _ = comptime {};
526648 \\ var good = {};
527649 \\ _ = comptime {}
528650 \\ var bad = {};
529651 \\}
530 , ".tmp_source.zig:5:5: error: expected token ';', found 'var'");
652 ,
653 ".tmp_source.zig:5:5: error: expected token ';', found 'var'",
654 );
531655
532 cases.add("implicit semicolon - defer",
656 cases.add(
657 "implicit semicolon - defer",
533658 \\export fn entry() void {
534659 \\ defer {}
535660 \\ var good = {};
536661 \\ defer ({})
537662 \\ var bad = {};
538663 \\}
539 , ".tmp_source.zig:5:5: error: expected token ';', found 'var'");
664 ,
665 ".tmp_source.zig:5:5: error: expected token ';', found 'var'",
666 );
540667
541 cases.add("implicit semicolon - if statement",
668 cases.add(
669 "implicit semicolon - if statement",
542670 \\export fn entry() void {
543671 \\ if(true) {}
544672 \\ var good = {};
545673 \\ if(true) ({})
546674 \\ var bad = {};
547675 \\}
548 , ".tmp_source.zig:5:5: error: expected token ';', found 'var'");
676 ,
677 ".tmp_source.zig:5:5: error: expected token ';', found 'var'",
678 );
549679
550 cases.add("implicit semicolon - if expression",
680 cases.add(
681 "implicit semicolon - if expression",
551682 \\export fn entry() void {
552683 \\ _ = if(true) {};
553684 \\ var good = {};
554685 \\ _ = if(true) {}
555686 \\ var bad = {};
556687 \\}
557 , ".tmp_source.zig:5:5: error: expected token ';', found 'var'");
688 ,
689 ".tmp_source.zig:5:5: error: expected token ';', found 'var'",
690 );
558691
559 cases.add("implicit semicolon - if-else statement",
692 cases.add(
693 "implicit semicolon - if-else statement",
560694 \\export fn entry() void {
561695 \\ if(true) {} else {}
562696 \\ var good = {};
563697 \\ if(true) ({}) else ({})
564698 \\ var bad = {};
565699 \\}
566 , ".tmp_source.zig:5:5: error: expected token ';', found 'var'");
700 ,
701 ".tmp_source.zig:5:5: error: expected token ';', found 'var'",
702 );
567703
568 cases.add("implicit semicolon - if-else expression",
704 cases.add(
705 "implicit semicolon - if-else expression",
569706 \\export fn entry() void {
570707 \\ _ = if(true) {} else {};
571708 \\ var good = {};
572709 \\ _ = if(true) {} else {}
573710 \\ var bad = {};
574711 \\}
575 , ".tmp_source.zig:5:5: error: expected token ';', found 'var'");
712 ,
713 ".tmp_source.zig:5:5: error: expected token ';', found 'var'",
714 );
576715
577 cases.add("implicit semicolon - if-else-if statement",
716 cases.add(
717 "implicit semicolon - if-else-if statement",
578718 \\export fn entry() void {
579719 \\ if(true) {} else if(true) {}
580720 \\ var good = {};
581721 \\ if(true) ({}) else if(true) ({})
582722 \\ var bad = {};
583723 \\}
584 , ".tmp_source.zig:5:5: error: expected token ';', found 'var'");
724 ,
725 ".tmp_source.zig:5:5: error: expected token ';', found 'var'",
726 );
585727
586 cases.add("implicit semicolon - if-else-if expression",
728 cases.add(
729 "implicit semicolon - if-else-if expression",
587730 \\export fn entry() void {
588731 \\ _ = if(true) {} else if(true) {};
589732 \\ var good = {};
590733 \\ _ = if(true) {} else if(true) {}
591734 \\ var bad = {};
592735 \\}
593 , ".tmp_source.zig:5:5: error: expected token ';', found 'var'");
736 ,
737 ".tmp_source.zig:5:5: error: expected token ';', found 'var'",
738 );
594739
595 cases.add("implicit semicolon - if-else-if-else statement",
740 cases.add(
741 "implicit semicolon - if-else-if-else statement",
596742 \\export fn entry() void {
597743 \\ if(true) {} else if(true) {} else {}
598744 \\ var good = {};
599745 \\ if(true) ({}) else if(true) ({}) else ({})
600746 \\ var bad = {};
601747 \\}
602 , ".tmp_source.zig:5:5: error: expected token ';', found 'var'");
748 ,
749 ".tmp_source.zig:5:5: error: expected token ';', found 'var'",
750 );
603751
604 cases.add("implicit semicolon - if-else-if-else expression",
752 cases.add(
753 "implicit semicolon - if-else-if-else expression",
605754 \\export fn entry() void {
606755 \\ _ = if(true) {} else if(true) {} else {};
607756 \\ var good = {};
608757 \\ _ = if(true) {} else if(true) {} else {}
609758 \\ var bad = {};
610759 \\}
611 , ".tmp_source.zig:5:5: error: expected token ';', found 'var'");
760 ,
761 ".tmp_source.zig:5:5: error: expected token ';', found 'var'",
762 );
612763
613 cases.add("implicit semicolon - test statement",
764 cases.add(
765 "implicit semicolon - test statement",
614766 \\export fn entry() void {
615767 \\ if (foo()) |_| {}
616768 \\ var good = {};
617769 \\ if (foo()) |_| ({})
618770 \\ var bad = {};
619771 \\}
620 , ".tmp_source.zig:5:5: error: expected token ';', found 'var'");
772 ,
773 ".tmp_source.zig:5:5: error: expected token ';', found 'var'",
774 );
621775
622 cases.add("implicit semicolon - test expression",
776 cases.add(
777 "implicit semicolon - test expression",
623778 \\export fn entry() void {
624779 \\ _ = if (foo()) |_| {};
625780 \\ var good = {};
626781 \\ _ = if (foo()) |_| {}
627782 \\ var bad = {};
628783 \\}
629 , ".tmp_source.zig:5:5: error: expected token ';', found 'var'");
784 ,
785 ".tmp_source.zig:5:5: error: expected token ';', found 'var'",
786 );
630787
631 cases.add("implicit semicolon - while statement",
788 cases.add(
789 "implicit semicolon - while statement",
632790 \\export fn entry() void {
633791 \\ while(true) {}
634792 \\ var good = {};
635793 \\ while(true) ({})
636794 \\ var bad = {};
637795 \\}
638 , ".tmp_source.zig:5:5: error: expected token ';', found 'var'");
796 ,
797 ".tmp_source.zig:5:5: error: expected token ';', found 'var'",
798 );
639799
640 cases.add("implicit semicolon - while expression",
800 cases.add(
801 "implicit semicolon - while expression",
641802 \\export fn entry() void {
642803 \\ _ = while(true) {};
643804 \\ var good = {};
644805 \\ _ = while(true) {}
645806 \\ var bad = {};
646807 \\}
647 , ".tmp_source.zig:5:5: error: expected token ';', found 'var'");
808 ,
809 ".tmp_source.zig:5:5: error: expected token ';', found 'var'",
810 );
648811
649 cases.add("implicit semicolon - while-continue statement",
812 cases.add(
813 "implicit semicolon - while-continue statement",
650814 \\export fn entry() void {
651815 \\ while(true):({}) {}
652816 \\ var good = {};
653817 \\ while(true):({}) ({})
654818 \\ var bad = {};
655819 \\}
656 , ".tmp_source.zig:5:5: error: expected token ';', found 'var'");
820 ,
821 ".tmp_source.zig:5:5: error: expected token ';', found 'var'",
822 );
657823
658 cases.add("implicit semicolon - while-continue expression",
824 cases.add(
825 "implicit semicolon - while-continue expression",
659826 \\export fn entry() void {
660827 \\ _ = while(true):({}) {};
661828 \\ var good = {};
662829 \\ _ = while(true):({}) {}
663830 \\ var bad = {};
664831 \\}
665 , ".tmp_source.zig:5:5: error: expected token ';', found 'var'");
832 ,
833 ".tmp_source.zig:5:5: error: expected token ';', found 'var'",
834 );
666835
667 cases.add("implicit semicolon - for statement",
836 cases.add(
837 "implicit semicolon - for statement",
668838 \\export fn entry() void {
669839 \\ for(foo()) {}
670840 \\ var good = {};
671841 \\ for(foo()) ({})
672842 \\ var bad = {};
673843 \\}
674 , ".tmp_source.zig:5:5: error: expected token ';', found 'var'");
844 ,
845 ".tmp_source.zig:5:5: error: expected token ';', found 'var'",
846 );
675847
676 cases.add("implicit semicolon - for expression",
848 cases.add(
849 "implicit semicolon - for expression",
677850 \\export fn entry() void {
678851 \\ _ = for(foo()) {};
679852 \\ var good = {};
680853 \\ _ = for(foo()) {}
681854 \\ var bad = {};
682855 \\}
683 , ".tmp_source.zig:5:5: error: expected token ';', found 'var'");
856 ,
857 ".tmp_source.zig:5:5: error: expected token ';', found 'var'",
858 );
684859
685 cases.add("multiple function definitions",
860 cases.add(
861 "multiple function definitions",
686862 \\fn a() void {}
687863 \\fn a() void {}
688864 \\export fn entry() void { a(); }
689 , ".tmp_source.zig:2:1: error: redefinition of 'a'");
865 ,
866 ".tmp_source.zig:2:1: error: redefinition of 'a'",
867 );
690868
691 cases.add("unreachable with return",
869 cases.add(
870 "unreachable with return",
692871 \\fn a() noreturn {return;}
693872 \\export fn entry() void { a(); }
694 , ".tmp_source.zig:1:18: error: expected type 'noreturn', found 'void'");
873 ,
874 ".tmp_source.zig:1:18: error: expected type 'noreturn', found 'void'",
875 );
695876
696 cases.add("control reaches end of non-void function",
877 cases.add(
878 "control reaches end of non-void function",
697879 \\fn a() i32 {}
698880 \\export fn entry() void { _ = a(); }
699 , ".tmp_source.zig:1:12: error: expected type 'i32', found 'void'");
881 ,
882 ".tmp_source.zig:1:12: error: expected type 'i32', found 'void'",
883 );
700884
701 cases.add("undefined function call",
885 cases.add(
886 "undefined function call",
702887 \\export fn a() void {
703888 \\ b();
704889 \\}
705 , ".tmp_source.zig:2:5: error: use of undeclared identifier 'b'");
890 ,
891 ".tmp_source.zig:2:5: error: use of undeclared identifier 'b'",
892 );
706893
707 cases.add("wrong number of arguments",
894 cases.add(
895 "wrong number of arguments",
708896 \\export fn a() void {
709897 \\ b(1);
710898 \\}
711899 \\fn b(a: i32, b: i32, c: i32) void { }
712 , ".tmp_source.zig:2:6: error: expected 3 arguments, found 1");
900 ,
901 ".tmp_source.zig:2:6: error: expected 3 arguments, found 1",
902 );
713903
714 cases.add("invalid type",
904 cases.add(
905 "invalid type",
715906 \\fn a() bogus {}
716907 \\export fn entry() void { _ = a(); }
717 , ".tmp_source.zig:1:8: error: use of undeclared identifier 'bogus'");
908 ,
909 ".tmp_source.zig:1:8: error: use of undeclared identifier 'bogus'",
910 );
718911
719 cases.add("pointer to noreturn",
912 cases.add(
913 "pointer to noreturn",
720914 \\fn a() &noreturn {}
721915 \\export fn entry() void { _ = a(); }
722 , ".tmp_source.zig:1:9: error: pointer to noreturn not allowed");
916 ,
917 ".tmp_source.zig:1:9: error: pointer to noreturn not allowed",
918 );
723919
724 cases.add("unreachable code",
920 cases.add(
921 "unreachable code",
725922 \\export fn a() void {
726923 \\ return;
727924 \\ b();
728925 \\}
729926 \\
730927 \\fn b() void {}
731 , ".tmp_source.zig:3:5: error: unreachable code");
928 ,
929 ".tmp_source.zig:3:5: error: unreachable code",
930 );
732931
733 cases.add("bad import",
734 \\const bogus = @import("bogus-does-not-exist.zig");
932 cases.add(
933 "bad import",
934 \\const bogus = @import("bogus-does-not-exist.zig",);
735935 \\export fn entry() void { bogus.bogo(); }
736 , ".tmp_source.zig:1:15: error: unable to find 'bogus-does-not-exist.zig'");
936 ,
937 ".tmp_source.zig:1:15: error: unable to find 'bogus-does-not-exist.zig'",
938 );
737939
738 cases.add("undeclared identifier",
940 cases.add(
941 "undeclared identifier",
739942 \\export fn a() void {
740943 \\ return
741944 \\ b +
742945 \\ c;
743946 \\}
744947 ,
745 ".tmp_source.zig:3:5: error: use of undeclared identifier 'b'",
746 ".tmp_source.zig:4:5: error: use of undeclared identifier 'c'");
948 ".tmp_source.zig:3:5: error: use of undeclared identifier 'b'",
949 ".tmp_source.zig:4:5: error: use of undeclared identifier 'c'",
950 );
747951
748 cases.add("parameter redeclaration",
952 cases.add(
953 "parameter redeclaration",
749954 \\fn f(a : i32, a : i32) void {
750955 \\}
751956 \\export fn entry() void { f(1, 2); }
752 , ".tmp_source.zig:1:15: error: redeclaration of variable 'a'");
957 ,
958 ".tmp_source.zig:1:15: error: redeclaration of variable 'a'",
959 );
753960
754 cases.add("local variable redeclaration",
961 cases.add(
962 "local variable redeclaration",
755963 \\export fn f() void {
756964 \\ const a : i32 = 0;
757965 \\ const a = 0;
758966 \\}
759 , ".tmp_source.zig:3:5: error: redeclaration of variable 'a'");
967 ,
968 ".tmp_source.zig:3:5: error: redeclaration of variable 'a'",
969 );
760970
761 cases.add("local variable redeclares parameter",
971 cases.add(
972 "local variable redeclares parameter",
762973 \\fn f(a : i32) void {
763974 \\ const a = 0;
764975 \\}
765976 \\export fn entry() void { f(1); }
766 , ".tmp_source.zig:2:5: error: redeclaration of variable 'a'");
977 ,
978 ".tmp_source.zig:2:5: error: redeclaration of variable 'a'",
979 );
767980
768 cases.add("variable has wrong type",
981 cases.add(
982 "variable has wrong type",
769983 \\export fn f() i32 {
770984 \\ const a = c"a";
771985 \\ return a;
772986 \\}
773 , ".tmp_source.zig:3:12: error: expected type 'i32', found '&const u8'");
987 ,
988 ".tmp_source.zig:3:12: error: expected type 'i32', found '&const u8'",
989 );
774990
775 cases.add("if condition is bool, not int",
991 cases.add(
992 "if condition is bool, not int",
776993 \\export fn f() void {
777994 \\ if (0) {}
778995 \\}
779 , ".tmp_source.zig:2:9: error: integer value 0 cannot be implicitly casted to type 'bool'");
996 ,
997 ".tmp_source.zig:2:9: error: integer value 0 cannot be implicitly casted to type 'bool'",
998 );
780999
781 cases.add("assign unreachable",
1000 cases.add(
1001 "assign unreachable",
7821002 \\export fn f() void {
7831003 \\ const a = return;
7841004 \\}
785 , ".tmp_source.zig:2:5: error: unreachable code");
1005 ,
1006 ".tmp_source.zig:2:5: error: unreachable code",
1007 );
7861008
787 cases.add("unreachable variable",
1009 cases.add(
1010 "unreachable variable",
7881011 \\export fn f() void {
7891012 \\ const a: noreturn = {};
7901013 \\}
791 , ".tmp_source.zig:2:14: error: variable of type 'noreturn' not allowed");
1014 ,
1015 ".tmp_source.zig:2:14: error: variable of type 'noreturn' not allowed",
1016 );
7921017
793 cases.add("unreachable parameter",
1018 cases.add(
1019 "unreachable parameter",
7941020 \\fn f(a: noreturn) void {}
7951021 \\export fn entry() void { f(); }
796 , ".tmp_source.zig:1:9: error: parameter of type 'noreturn' not allowed");
1022 ,
1023 ".tmp_source.zig:1:9: error: parameter of type 'noreturn' not allowed",
1024 );
7971025
798 cases.add("bad assignment target",
1026 cases.add(
1027 "bad assignment target",
7991028 \\export fn f() void {
8001029 \\ 3 = 3;
8011030 \\}
802 , ".tmp_source.zig:2:7: error: cannot assign to constant");
1031 ,
1032 ".tmp_source.zig:2:7: error: cannot assign to constant",
1033 );
8031034
804 cases.add("assign to constant variable",
1035 cases.add(
1036 "assign to constant variable",
8051037 \\export fn f() void {
8061038 \\ const a = 3;
8071039 \\ a = 4;
8081040 \\}
809 , ".tmp_source.zig:3:7: error: cannot assign to constant");
1041 ,
1042 ".tmp_source.zig:3:7: error: cannot assign to constant",
1043 );
8101044
811 cases.add("use of undeclared identifier",
1045 cases.add(
1046 "use of undeclared identifier",
8121047 \\export fn f() void {
8131048 \\ b = 3;
8141049 \\}
815 , ".tmp_source.zig:2:5: error: use of undeclared identifier 'b'");
1050 ,
1051 ".tmp_source.zig:2:5: error: use of undeclared identifier 'b'",
1052 );
8161053
817 cases.add("const is a statement, not an expression",
1054 cases.add(
1055 "const is a statement, not an expression",
8181056 \\export fn f() void {
8191057 \\ (const a = 0);
8201058 \\}
821 , ".tmp_source.zig:2:6: error: invalid token: 'const'");
1059 ,
1060 ".tmp_source.zig:2:6: error: invalid token: 'const'",
1061 );
8221062
823 cases.add("array access of undeclared identifier",
1063 cases.add(
1064 "array access of undeclared identifier",
8241065 \\export fn f() void {
8251066 \\ i[i] = i[i];
8261067 \\}
827 , ".tmp_source.zig:2:5: error: use of undeclared identifier 'i'",
828 ".tmp_source.zig:2:12: error: use of undeclared identifier 'i'");
1068 ,
1069 ".tmp_source.zig:2:5: error: use of undeclared identifier 'i'",
1070 ".tmp_source.zig:2:12: error: use of undeclared identifier 'i'",
1071 );
8291072
830 cases.add("array access of non array",
1073 cases.add(
1074 "array access of non array",
8311075 \\export fn f() void {
8321076 \\ var bad : bool = undefined;
8331077 \\ bad[bad] = bad[bad];
8341078 \\}
835 , ".tmp_source.zig:3:8: error: array access of non-array type 'bool'",
836 ".tmp_source.zig:3:19: error: array access of non-array type 'bool'");
1079 ,
1080 ".tmp_source.zig:3:8: error: array access of non-array type 'bool'",
1081 ".tmp_source.zig:3:19: error: array access of non-array type 'bool'",
1082 );
8371083
838 cases.add("array access with non integer index",
1084 cases.add(
1085 "array access with non integer index",
8391086 \\export fn f() void {
8401087 \\ var array = "aoeu";
8411088 \\ var bad = false;
8421089 \\ array[bad] = array[bad];
8431090 \\}
844 , ".tmp_source.zig:4:11: error: expected type 'usize', found 'bool'",
845 ".tmp_source.zig:4:24: error: expected type 'usize', found 'bool'");
1091 ,
1092 ".tmp_source.zig:4:11: error: expected type 'usize', found 'bool'",
1093 ".tmp_source.zig:4:24: error: expected type 'usize', found 'bool'",
1094 );
8461095
847 cases.add("write to const global variable",
1096 cases.add(
1097 "write to const global variable",
8481098 \\const x : i32 = 99;
8491099 \\fn f() void {
8501100 \\ x = 1;
8511101 \\}
8521102 \\export fn entry() void { f(); }
853 , ".tmp_source.zig:3:7: error: cannot assign to constant");
854
1103 ,
1104 ".tmp_source.zig:3:7: error: cannot assign to constant",
1105 );
8551106
856 cases.add("missing else clause",
1107 cases.add(
1108 "missing else clause",
8571109 \\fn f(b: bool) void {
8581110 \\ const x : i32 = if (b) h: { break :h 1; };
8591111 \\ const y = if (b) h: { break :h i32(1); };
8601112 \\}
8611113 \\export fn entry() void { f(true); }
862 , ".tmp_source.zig:2:42: error: integer value 1 cannot be implicitly casted to type 'void'",
863 ".tmp_source.zig:3:15: error: incompatible types: 'i32' and 'void'");
1114 ,
1115 ".tmp_source.zig:2:42: error: integer value 1 cannot be implicitly casted to type 'void'",
1116 ".tmp_source.zig:3:15: error: incompatible types: 'i32' and 'void'",
1117 );
8641118
865 cases.add("direct struct loop",
1119 cases.add(
1120 "direct struct loop",
8661121 \\const A = struct { a : A, };
8671122 \\export fn entry() usize { return @sizeOf(A); }
868 , ".tmp_source.zig:1:11: error: struct 'A' contains itself");
1123 ,
1124 ".tmp_source.zig:1:11: error: struct 'A' contains itself",
1125 );
8691126
870 cases.add("indirect struct loop",
1127 cases.add(
1128 "indirect struct loop",
8711129 \\const A = struct { b : B, };
8721130 \\const B = struct { c : C, };
8731131 \\const C = struct { a : A, };
8741132 \\export fn entry() usize { return @sizeOf(A); }
875 , ".tmp_source.zig:1:11: error: struct 'A' contains itself");
1133 ,
1134 ".tmp_source.zig:1:11: error: struct 'A' contains itself",
1135 );
8761136
877 cases.add("invalid struct field",
1137 cases.add(
1138 "invalid struct field",
8781139 \\const A = struct { x : i32, };
8791140 \\export fn f() void {
8801141 \\ var a : A = undefined;
......@@ -882,27 +1143,37 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
8821143 \\ const y = a.bar;
8831144 \\}
8841145 ,
885 ".tmp_source.zig:4:6: error: no member named 'foo' in struct 'A'",
886 ".tmp_source.zig:5:16: error: no member named 'bar' in struct 'A'");
1146 ".tmp_source.zig:4:6: error: no member named 'foo' in struct 'A'",
1147 ".tmp_source.zig:5:16: error: no member named 'bar' in struct 'A'",
1148 );
8871149
888 cases.add("redefinition of struct",
1150 cases.add(
1151 "redefinition of struct",
8891152 \\const A = struct { x : i32, };
8901153 \\const A = struct { y : i32, };
891 , ".tmp_source.zig:2:1: error: redefinition of 'A'");
1154 ,
1155 ".tmp_source.zig:2:1: error: redefinition of 'A'",
1156 );
8921157
893 cases.add("redefinition of enums",
1158 cases.add(
1159 "redefinition of enums",
8941160 \\const A = enum {};
8951161 \\const A = enum {};
896 , ".tmp_source.zig:2:1: error: redefinition of 'A'");
1162 ,
1163 ".tmp_source.zig:2:1: error: redefinition of 'A'",
1164 );
8971165
898 cases.add("redefinition of global variables",
1166 cases.add(
1167 "redefinition of global variables",
8991168 \\var a : i32 = 1;
9001169 \\var a : i32 = 2;
9011170 ,
902 ".tmp_source.zig:2:1: error: redefinition of 'a'",
903 ".tmp_source.zig:1:1: note: previous definition is here");
1171 ".tmp_source.zig:2:1: error: redefinition of 'a'",
1172 ".tmp_source.zig:1:1: note: previous definition is here",
1173 );
9041174
905 cases.add("duplicate field in struct value expression",
1175 cases.add(
1176 "duplicate field in struct value expression",
9061177 \\const A = struct {
9071178 \\ x : i32,
9081179 \\ y : i32,
......@@ -916,9 +1187,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
9161187 \\ .z = 4,
9171188 \\ };
9181189 \\}
919 , ".tmp_source.zig:11:9: error: duplicate field");
1190 ,
1191 ".tmp_source.zig:11:9: error: duplicate field",
1192 );
9201193
921 cases.add("missing field in struct value expression",
1194 cases.add(
1195 "missing field in struct value expression",
9221196 \\const A = struct {
9231197 \\ x : i32,
9241198 \\ y : i32,
......@@ -932,9 +1206,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
9321206 \\ .y = 2,
9331207 \\ };
9341208 \\}
935 , ".tmp_source.zig:9:17: error: missing field: 'x'");
1209 ,
1210 ".tmp_source.zig:9:17: error: missing field: 'x'",
1211 );
9361212
937 cases.add("invalid field in struct value expression",
1213 cases.add(
1214 "invalid field in struct value expression",
9381215 \\const A = struct {
9391216 \\ x : i32,
9401217 \\ y : i32,
......@@ -947,66 +1224,95 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
9471224 \\ .foo = 42,
9481225 \\ };
9491226 \\}
950 , ".tmp_source.zig:10:9: error: no member named 'foo' in struct 'A'");
1227 ,
1228 ".tmp_source.zig:10:9: error: no member named 'foo' in struct 'A'",
1229 );
9511230
952 cases.add("invalid break expression",
1231 cases.add(
1232 "invalid break expression",
9531233 \\export fn f() void {
9541234 \\ break;
9551235 \\}
956 , ".tmp_source.zig:2:5: error: break expression outside loop");
1236 ,
1237 ".tmp_source.zig:2:5: error: break expression outside loop",
1238 );
9571239
958 cases.add("invalid continue expression",
1240 cases.add(
1241 "invalid continue expression",
9591242 \\export fn f() void {
9601243 \\ continue;
9611244 \\}
962 , ".tmp_source.zig:2:5: error: continue expression outside loop");
1245 ,
1246 ".tmp_source.zig:2:5: error: continue expression outside loop",
1247 );
9631248
964 cases.add("invalid maybe type",
1249 cases.add(
1250 "invalid maybe type",
9651251 \\export fn f() void {
9661252 \\ if (true) |x| { }
9671253 \\}
968 , ".tmp_source.zig:2:9: error: expected nullable type, found 'bool'");
1254 ,
1255 ".tmp_source.zig:2:9: error: expected nullable type, found 'bool'",
1256 );
9691257
970 cases.add("cast unreachable",
1258 cases.add(
1259 "cast unreachable",
9711260 \\fn f() i32 {
9721261 \\ return i32(return 1);
9731262 \\}
9741263 \\export fn entry() void { _ = f(); }
975 , ".tmp_source.zig:2:15: error: unreachable code");
1264 ,
1265 ".tmp_source.zig:2:15: error: unreachable code",
1266 );
9761267
977 cases.add("invalid builtin fn",
1268 cases.add(
1269 "invalid builtin fn",
9781270 \\fn f() @bogus(foo) {
9791271 \\}
9801272 \\export fn entry() void { _ = f(); }
981 , ".tmp_source.zig:1:8: error: invalid builtin function: 'bogus'");
1273 ,
1274 ".tmp_source.zig:1:8: error: invalid builtin function: 'bogus'",
1275 );
9821276
983 cases.add("top level decl dependency loop",
1277 cases.add(
1278 "top level decl dependency loop",
9841279 \\const a : @typeOf(b) = 0;
9851280 \\const b : @typeOf(a) = 0;
9861281 \\export fn entry() void {
9871282 \\ const c = a + b;
9881283 \\}
989 , ".tmp_source.zig:1:1: error: 'a' depends on itself");
1284 ,
1285 ".tmp_source.zig:1:1: error: 'a' depends on itself",
1286 );
9901287
991 cases.add("noalias on non pointer param",
1288 cases.add(
1289 "noalias on non pointer param",
9921290 \\fn f(noalias x: i32) void {}
9931291 \\export fn entry() void { f(1234); }
994 , ".tmp_source.zig:1:6: error: noalias on non-pointer parameter");
1292 ,
1293 ".tmp_source.zig:1:6: error: noalias on non-pointer parameter",
1294 );
9951295
996 cases.add("struct init syntax for array",
1296 cases.add(
1297 "struct init syntax for array",
9971298 \\const foo = []u16{.x = 1024,};
9981299 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
999 , ".tmp_source.zig:1:18: error: type '[]u16' does not support struct initialization syntax");
1300 ,
1301 ".tmp_source.zig:1:18: error: type '[]u16' does not support struct initialization syntax",
1302 );
10001303
1001 cases.add("type variables must be constant",
1304 cases.add(
1305 "type variables must be constant",
10021306 \\var foo = u8;
10031307 \\export fn entry() foo {
10041308 \\ return 1;
10051309 \\}
1006 , ".tmp_source.zig:1:1: error: variable of type 'type' must be constant");
1007
1310 ,
1311 ".tmp_source.zig:1:1: error: variable of type 'type' must be constant",
1312 );
10081313
1009 cases.add("variables shadowing types",
1314 cases.add(
1315 "variables shadowing types",
10101316 \\const Foo = struct {};
10111317 \\const Bar = struct {};
10121318 \\
......@@ -1018,12 +1324,14 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
10181324 \\ f(1234);
10191325 \\}
10201326 ,
1021 ".tmp_source.zig:4:6: error: redefinition of 'Foo'",
1022 ".tmp_source.zig:1:1: note: previous definition is here",
1023 ".tmp_source.zig:5:5: error: redefinition of 'Bar'",
1024 ".tmp_source.zig:2:1: note: previous definition is here");
1327 ".tmp_source.zig:4:6: error: redefinition of 'Foo'",
1328 ".tmp_source.zig:1:1: note: previous definition is here",
1329 ".tmp_source.zig:5:5: error: redefinition of 'Bar'",
1330 ".tmp_source.zig:2:1: note: previous definition is here",
1331 );
10251332
1026 cases.add("switch expression - missing enumeration prong",
1333 cases.add(
1334 "switch expression - missing enumeration prong",
10271335 \\const Number = enum {
10281336 \\ One,
10291337 \\ Two,
......@@ -1039,9 +1347,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
10391347 \\}
10401348 \\
10411349 \\export fn entry() usize { return @sizeOf(@typeOf(f)); }
1042 , ".tmp_source.zig:8:5: error: enumeration value 'Number.Four' not handled in switch");
1350 ,
1351 ".tmp_source.zig:8:5: error: enumeration value 'Number.Four' not handled in switch",
1352 );
10431353
1044 cases.add("switch expression - duplicate enumeration prong",
1354 cases.add(
1355 "switch expression - duplicate enumeration prong",
10451356 \\const Number = enum {
10461357 \\ One,
10471358 \\ Two,
......@@ -1059,10 +1370,13 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
10591370 \\}
10601371 \\
10611372 \\export fn entry() usize { return @sizeOf(@typeOf(f)); }
1062 , ".tmp_source.zig:13:15: error: duplicate switch value",
1063 ".tmp_source.zig:10:15: note: other value is here");
1373 ,
1374 ".tmp_source.zig:13:15: error: duplicate switch value",
1375 ".tmp_source.zig:10:15: note: other value is here",
1376 );
10641377
1065 cases.add("switch expression - duplicate enumeration prong when else present",
1378 cases.add(
1379 "switch expression - duplicate enumeration prong when else present",
10661380 \\const Number = enum {
10671381 \\ One,
10681382 \\ Two,
......@@ -1081,10 +1395,13 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
10811395 \\}
10821396 \\
10831397 \\export fn entry() usize { return @sizeOf(@typeOf(f)); }
1084 , ".tmp_source.zig:13:15: error: duplicate switch value",
1085 ".tmp_source.zig:10:15: note: other value is here");
1398 ,
1399 ".tmp_source.zig:13:15: error: duplicate switch value",
1400 ".tmp_source.zig:10:15: note: other value is here",
1401 );
10861402
1087 cases.add("switch expression - multiple else prongs",
1403 cases.add(
1404 "switch expression - multiple else prongs",
10881405 \\fn f(x: u32) void {
10891406 \\ const value: bool = switch (x) {
10901407 \\ 1234 => false,
......@@ -1095,9 +1412,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
10951412 \\export fn entry() void {
10961413 \\ f(1234);
10971414 \\}
1098 , ".tmp_source.zig:5:9: error: multiple else prongs in switch expression");
1415 ,
1416 ".tmp_source.zig:5:9: error: multiple else prongs in switch expression",
1417 );
10991418
1100 cases.add("switch expression - non exhaustive integer prongs",
1419 cases.add(
1420 "switch expression - non exhaustive integer prongs",
11011421 \\fn foo(x: u8) void {
11021422 \\ switch (x) {
11031423 \\ 0 => {},
......@@ -1105,9 +1425,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
11051425 \\}
11061426 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
11071427 ,
1108 ".tmp_source.zig:2:5: error: switch must handle all possibilities");
1428 ".tmp_source.zig:2:5: error: switch must handle all possibilities",
1429 );
11091430
1110 cases.add("switch expression - duplicate or overlapping integer value",
1431 cases.add(
1432 "switch expression - duplicate or overlapping integer value",
11111433 \\fn foo(x: u8) u8 {
11121434 \\ return switch (x) {
11131435 \\ 0 ... 100 => u8(0),
......@@ -1119,9 +1441,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
11191441 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
11201442 ,
11211443 ".tmp_source.zig:6:9: error: duplicate switch value",
1122 ".tmp_source.zig:5:14: note: previous value is here");
1444 ".tmp_source.zig:5:14: note: previous value is here",
1445 );
11231446
1124 cases.add("switch expression - switch on pointer type with no else",
1447 cases.add(
1448 "switch expression - switch on pointer type with no else",
11251449 \\fn foo(x: &u8) void {
11261450 \\ switch (x) {
11271451 \\ &y => {},
......@@ -1130,54 +1454,77 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
11301454 \\const y: u8 = 100;
11311455 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
11321456 ,
1133 ".tmp_source.zig:2:5: error: else prong required when switching on type '&u8'");
1457 ".tmp_source.zig:2:5: error: else prong required when switching on type '&u8'",
1458 );
11341459
1135 cases.add("global variable initializer must be constant expression",
1460 cases.add(
1461 "global variable initializer must be constant expression",
11361462 \\extern fn foo() i32;
11371463 \\const x = foo();
11381464 \\export fn entry() i32 { return x; }
1139 , ".tmp_source.zig:2:11: error: unable to evaluate constant expression");
1465 ,
1466 ".tmp_source.zig:2:11: error: unable to evaluate constant expression",
1467 );
11401468
1141 cases.add("array concatenation with wrong type",
1469 cases.add(
1470 "array concatenation with wrong type",
11421471 \\const src = "aoeu";
11431472 \\const derp = usize(1234);
11441473 \\const a = derp ++ "foo";
11451474 \\
11461475 \\export fn entry() usize { return @sizeOf(@typeOf(a)); }
1147 , ".tmp_source.zig:3:11: error: expected array or C string literal, found 'usize'");
1476 ,
1477 ".tmp_source.zig:3:11: error: expected array or C string literal, found 'usize'",
1478 );
11481479
1149 cases.add("non compile time array concatenation",
1480 cases.add(
1481 "non compile time array concatenation",
11501482 \\fn f() []u8 {
11511483 \\ return s ++ "foo";
11521484 \\}
11531485 \\var s: [10]u8 = undefined;
11541486 \\export fn entry() usize { return @sizeOf(@typeOf(f)); }
1155 , ".tmp_source.zig:2:12: error: unable to evaluate constant expression");
1487 ,
1488 ".tmp_source.zig:2:12: error: unable to evaluate constant expression",
1489 );
11561490
1157 cases.add("@cImport with bogus include",
1491 cases.add(
1492 "@cImport with bogus include",
11581493 \\const c = @cImport(@cInclude("bogus.h"));
11591494 \\export fn entry() usize { return @sizeOf(@typeOf(c.bogo)); }
1160 , ".tmp_source.zig:1:11: error: C import failed",
1161 ".h:1:10: note: 'bogus.h' file not found");
1495 ,
1496 ".tmp_source.zig:1:11: error: C import failed",
1497 ".h:1:10: note: 'bogus.h' file not found",
1498 );
11621499
1163 cases.add("address of number literal",
1500 cases.add(
1501 "address of number literal",
11641502 \\const x = 3;
11651503 \\const y = &x;
11661504 \\fn foo() &const i32 { return y; }
11671505 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
1168 , ".tmp_source.zig:3:30: error: expected type '&const i32', found '&const (integer literal)'");
1506 ,
1507 ".tmp_source.zig:3:30: error: expected type '&const i32', found '&const (integer literal)'",
1508 );
11691509
1170 cases.add("integer overflow error",
1510 cases.add(
1511 "integer overflow error",
11711512 \\const x : u8 = 300;
11721513 \\export fn entry() usize { return @sizeOf(@typeOf(x)); }
1173 , ".tmp_source.zig:1:16: error: integer value 300 cannot be implicitly casted to type 'u8'");
1514 ,
1515 ".tmp_source.zig:1:16: error: integer value 300 cannot be implicitly casted to type 'u8'",
1516 );
11741517
1175 cases.add("incompatible number literals",
1518 cases.add(
1519 "incompatible number literals",
11761520 \\const x = 2 == 2.0;
11771521 \\export fn entry() usize { return @sizeOf(@typeOf(x)); }
1178 , ".tmp_source.zig:1:11: error: integer value 2 cannot be implicitly casted to type '(float literal)'");
1522 ,
1523 ".tmp_source.zig:1:11: error: integer value 2 cannot be implicitly casted to type '(float literal)'",
1524 );
11791525
1180 cases.add("missing function call param",
1526 cases.add(
1527 "missing function call param",
11811528 \\const Foo = struct {
11821529 \\ a: i32,
11831530 \\ b: i32,
......@@ -1201,58 +1548,73 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
12011548 \\}
12021549 \\
12031550 \\export fn entry() usize { return @sizeOf(@typeOf(f)); }
1204 , ".tmp_source.zig:20:34: error: expected 1 arguments, found 0");
1551 ,
1552 ".tmp_source.zig:20:34: error: expected 1 arguments, found 0",
1553 );
12051554
1206 cases.add("missing function name and param name",
1555 cases.add(
1556 "missing function name and param name",
12071557 \\fn () void {}
12081558 \\fn f(i32) void {}
12091559 \\export fn entry() usize { return @sizeOf(@typeOf(f)); }
12101560 ,
1211 ".tmp_source.zig:1:1: error: missing function name",
1212 ".tmp_source.zig:2:6: error: missing parameter name");
1561 ".tmp_source.zig:1:1: error: missing function name",
1562 ".tmp_source.zig:2:6: error: missing parameter name",
1563 );
12131564
1214 cases.add("wrong function type",
1565 cases.add(
1566 "wrong function type",
12151567 \\const fns = []fn() void { a, b, c };
12161568 \\fn a() i32 {return 0;}
12171569 \\fn b() i32 {return 1;}
12181570 \\fn c() i32 {return 2;}
12191571 \\export fn entry() usize { return @sizeOf(@typeOf(fns)); }
1220 , ".tmp_source.zig:1:27: error: expected type 'fn() void', found 'fn() i32'");
1572 ,
1573 ".tmp_source.zig:1:27: error: expected type 'fn() void', found 'fn() i32'",
1574 );
12211575
1222 cases.add("extern function pointer mismatch",
1576 cases.add(
1577 "extern function pointer mismatch",
12231578 \\const fns = [](fn(i32)i32) { a, b, c };
12241579 \\pub fn a(x: i32) i32 {return x + 0;}
12251580 \\pub fn b(x: i32) i32 {return x + 1;}
12261581 \\export fn c(x: i32) i32 {return x + 2;}
12271582 \\
12281583 \\export fn entry() usize { return @sizeOf(@typeOf(fns)); }
1229 , ".tmp_source.zig:1:36: error: expected type 'fn(i32) i32', found 'extern fn(i32) i32'");
1230
1584 ,
1585 ".tmp_source.zig:1:36: error: expected type 'fn(i32) i32', found 'extern fn(i32) i32'",
1586 );
12311587
1232 cases.add("implicit cast from f64 to f32",
1588 cases.add(
1589 "implicit cast from f64 to f32",
12331590 \\const x : f64 = 1.0;
12341591 \\const y : f32 = x;
12351592 \\
12361593 \\export fn entry() usize { return @sizeOf(@typeOf(y)); }
1237 , ".tmp_source.zig:2:17: error: expected type 'f32', found 'f64'");
1238
1594 ,
1595 ".tmp_source.zig:2:17: error: expected type 'f32', found 'f64'",
1596 );
12391597
1240 cases.add("colliding invalid top level functions",
1598 cases.add(
1599 "colliding invalid top level functions",
12411600 \\fn func() bogus {}
12421601 \\fn func() bogus {}
12431602 \\export fn entry() usize { return @sizeOf(@typeOf(func)); }
12441603 ,
1245 ".tmp_source.zig:2:1: error: redefinition of 'func'",
1246 ".tmp_source.zig:1:11: error: use of undeclared identifier 'bogus'");
1604 ".tmp_source.zig:2:1: error: redefinition of 'func'",
1605 ".tmp_source.zig:1:11: error: use of undeclared identifier 'bogus'",
1606 );
12471607
1248
1249 cases.add("bogus compile var",
1608 cases.add(
1609 "bogus compile var",
12501610 \\const x = @import("builtin").bogus;
12511611 \\export fn entry() usize { return @sizeOf(@typeOf(x)); }
1252 , ".tmp_source.zig:1:29: error: no member named 'bogus' in '");
1253
1612 ,
1613 ".tmp_source.zig:1:29: error: no member named 'bogus' in '",
1614 );
12541615
1255 cases.add("non constant expression in array size outside function",
1616 cases.add(
1617 "non constant expression in array size outside function",
12561618 \\const Foo = struct {
12571619 \\ y: [get()]u8,
12581620 \\};
......@@ -1261,22 +1623,25 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
12611623 \\
12621624 \\export fn entry() usize { return @sizeOf(@typeOf(Foo)); }
12631625 ,
1264 ".tmp_source.zig:5:25: error: unable to evaluate constant expression",
1265 ".tmp_source.zig:2:12: note: called from here",
1266 ".tmp_source.zig:2:8: note: called from here");
1267
1626 ".tmp_source.zig:5:25: error: unable to evaluate constant expression",
1627 ".tmp_source.zig:2:12: note: called from here",
1628 ".tmp_source.zig:2:8: note: called from here",
1629 );
12681630
1269 cases.add("addition with non numbers",
1631 cases.add(
1632 "addition with non numbers",
12701633 \\const Foo = struct {
12711634 \\ field: i32,
12721635 \\};
12731636 \\const x = Foo {.field = 1} + Foo {.field = 2};
12741637 \\
12751638 \\export fn entry() usize { return @sizeOf(@typeOf(x)); }
1276 , ".tmp_source.zig:4:28: error: invalid operands to binary expression: 'Foo' and 'Foo'");
1277
1639 ,
1640 ".tmp_source.zig:4:28: error: invalid operands to binary expression: 'Foo' and 'Foo'",
1641 );
12781642
1279 cases.add("division by zero",
1643 cases.add(
1644 "division by zero",
12801645 \\const lit_int_x = 1 / 0;
12811646 \\const lit_float_x = 1.0 / 0.0;
12821647 \\const int_x = u32(1) / u32(0);
......@@ -1287,49 +1652,65 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
12871652 \\export fn entry3() usize { return @sizeOf(@typeOf(int_x)); }
12881653 \\export fn entry4() usize { return @sizeOf(@typeOf(float_x)); }
12891654 ,
1290 ".tmp_source.zig:1:21: error: division by zero",
1291 ".tmp_source.zig:2:25: error: division by zero",
1292 ".tmp_source.zig:3:22: error: division by zero",
1293 ".tmp_source.zig:4:26: error: division by zero");
1294
1655 ".tmp_source.zig:1:21: error: division by zero",
1656 ".tmp_source.zig:2:25: error: division by zero",
1657 ".tmp_source.zig:3:22: error: division by zero",
1658 ".tmp_source.zig:4:26: error: division by zero",
1659 );
12951660
1296 cases.add("normal string with newline",
1661 cases.add(
1662 "normal string with newline",
12971663 \\const foo = "a
12981664 \\b";
12991665 \\
13001666 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
1301 , ".tmp_source.zig:1:13: error: newline not allowed in string literal");
1667 ,
1668 ".tmp_source.zig:1:13: error: newline not allowed in string literal",
1669 );
13021670
1303 cases.add("invalid comparison for function pointers",
1671 cases.add(
1672 "invalid comparison for function pointers",
13041673 \\fn foo() void {}
13051674 \\const invalid = foo > foo;
13061675 \\
13071676 \\export fn entry() usize { return @sizeOf(@typeOf(invalid)); }
1308 , ".tmp_source.zig:2:21: error: operator not allowed for type 'fn() void'");
1677 ,
1678 ".tmp_source.zig:2:21: error: operator not allowed for type 'fn() void'",
1679 );
13091680
1310 cases.add("generic function instance with non-constant expression",
1681 cases.add(
1682 "generic function instance with non-constant expression",
13111683 \\fn foo(comptime x: i32, y: i32) i32 { return x + y; }
13121684 \\fn test1(a: i32, b: i32) i32 {
13131685 \\ return foo(a, b);
13141686 \\}
13151687 \\
13161688 \\export fn entry() usize { return @sizeOf(@typeOf(test1)); }
1317 , ".tmp_source.zig:3:16: error: unable to evaluate constant expression");
1689 ,
1690 ".tmp_source.zig:3:16: error: unable to evaluate constant expression",
1691 );
13181692
1319 cases.add("assign null to non-nullable pointer",
1693 cases.add(
1694 "assign null to non-nullable pointer",
13201695 \\const a: &u8 = null;
13211696 \\
13221697 \\export fn entry() usize { return @sizeOf(@typeOf(a)); }
1323 , ".tmp_source.zig:1:16: error: expected type '&u8', found '(null)'");
1698 ,
1699 ".tmp_source.zig:1:16: error: expected type '&u8', found '(null)'",
1700 );
13241701
1325 cases.add("indexing an array of size zero",
1702 cases.add(
1703 "indexing an array of size zero",
13261704 \\const array = []u8{};
13271705 \\export fn foo() void {
13281706 \\ const pointer = &array[0];
13291707 \\}
1330 , ".tmp_source.zig:3:27: error: index 0 outside array of size 0");
1708 ,
1709 ".tmp_source.zig:3:27: error: index 0 outside array of size 0",
1710 );
13311711
1332 cases.add("compile time division by zero",
1712 cases.add(
1713 "compile time division by zero",
13331714 \\const y = foo(0);
13341715 \\fn foo(x: u32) u32 {
13351716 \\ return 1 / x;
......@@ -1337,17 +1718,21 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
13371718 \\
13381719 \\export fn entry() usize { return @sizeOf(@typeOf(y)); }
13391720 ,
1340 ".tmp_source.zig:3:14: error: division by zero",
1341 ".tmp_source.zig:1:14: note: called from here");
1721 ".tmp_source.zig:3:14: error: division by zero",
1722 ".tmp_source.zig:1:14: note: called from here",
1723 );
13421724
1343 cases.add("branch on undefined value",
1725 cases.add(
1726 "branch on undefined value",
13441727 \\const x = if (undefined) true else false;
13451728 \\
13461729 \\export fn entry() usize { return @sizeOf(@typeOf(x)); }
1347 , ".tmp_source.zig:1:15: error: use of undefined value");
1348
1730 ,
1731 ".tmp_source.zig:1:15: error: use of undefined value",
1732 );
13491733
1350 cases.add("endless loop in function evaluation",
1734 cases.add(
1735 "endless loop in function evaluation",
13511736 \\const seventh_fib_number = fibbonaci(7);
13521737 \\fn fibbonaci(x: i32) i32 {
13531738 \\ return fibbonaci(x - 1) + fibbonaci(x - 2);
......@@ -1355,16 +1740,22 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
13551740 \\
13561741 \\export fn entry() usize { return @sizeOf(@typeOf(seventh_fib_number)); }
13571742 ,
1358 ".tmp_source.zig:3:21: error: evaluation exceeded 1000 backwards branches",
1359 ".tmp_source.zig:3:21: note: called from here");
1743 ".tmp_source.zig:3:21: error: evaluation exceeded 1000 backwards branches",
1744 ".tmp_source.zig:3:21: note: called from here",
1745 );
13601746
1361 cases.add("@embedFile with bogus file",
1362 \\const resource = @embedFile("bogus.txt");
1747 cases.add(
1748 "@embedFile with bogus file",
1749 \\const resource = @embedFile("bogus.txt",);
13631750 \\
13641751 \\export fn entry() usize { return @sizeOf(@typeOf(resource)); }
1365 , ".tmp_source.zig:1:29: error: unable to find '", "bogus.txt'");
1752 ,
1753 ".tmp_source.zig:1:29: error: unable to find '",
1754 "bogus.txt'",
1755 );
13661756
1367 cases.add("non-const expression in struct literal outside function",
1757 cases.add(
1758 "non-const expression in struct literal outside function",
13681759 \\const Foo = struct {
13691760 \\ x: i32,
13701761 \\};
......@@ -1372,9 +1763,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
13721763 \\extern fn get_it() i32;
13731764 \\
13741765 \\export fn entry() usize { return @sizeOf(@typeOf(a)); }
1375 , ".tmp_source.zig:4:21: error: unable to evaluate constant expression");
1766 ,
1767 ".tmp_source.zig:4:21: error: unable to evaluate constant expression",
1768 );
13761769
1377 cases.add("non-const expression function call with struct return value outside function",
1770 cases.add(
1771 "non-const expression function call with struct return value outside function",
13781772 \\const Foo = struct {
13791773 \\ x: i32,
13801774 \\};
......@@ -1387,19 +1781,24 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
13871781 \\
13881782 \\export fn entry() usize { return @sizeOf(@typeOf(a)); }
13891783 ,
1390 ".tmp_source.zig:6:24: error: unable to evaluate constant expression",
1391 ".tmp_source.zig:4:17: note: called from here");
1784 ".tmp_source.zig:6:24: error: unable to evaluate constant expression",
1785 ".tmp_source.zig:4:17: note: called from here",
1786 );
13921787
1393 cases.add("undeclared identifier error should mark fn as impure",
1788 cases.add(
1789 "undeclared identifier error should mark fn as impure",
13941790 \\export fn foo() void {
13951791 \\ test_a_thing();
13961792 \\}
13971793 \\fn test_a_thing() void {
13981794 \\ bad_fn_call();
13991795 \\}
1400 , ".tmp_source.zig:5:5: error: use of undeclared identifier 'bad_fn_call'");
1796 ,
1797 ".tmp_source.zig:5:5: error: use of undeclared identifier 'bad_fn_call'",
1798 );
14011799
1402 cases.add("illegal comparison of types",
1800 cases.add(
1801 "illegal comparison of types",
14031802 \\fn bad_eql_1(a: []u8, b: []u8) bool {
14041803 \\ return a == b;
14051804 \\}
......@@ -1414,10 +1813,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
14141813 \\export fn entry1() usize { return @sizeOf(@typeOf(bad_eql_1)); }
14151814 \\export fn entry2() usize { return @sizeOf(@typeOf(bad_eql_2)); }
14161815 ,
1417 ".tmp_source.zig:2:14: error: operator not allowed for type '[]u8'",
1418 ".tmp_source.zig:9:16: error: operator not allowed for type 'EnumWithData'");
1816 ".tmp_source.zig:2:14: error: operator not allowed for type '[]u8'",
1817 ".tmp_source.zig:9:16: error: operator not allowed for type 'EnumWithData'",
1818 );
14191819
1420 cases.add("non-const switch number literal",
1820 cases.add(
1821 "non-const switch number literal",
14211822 \\export fn foo() void {
14221823 \\ const x = switch (bar()) {
14231824 \\ 1, 2 => 1,
......@@ -1428,25 +1829,34 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
14281829 \\fn bar() i32 {
14291830 \\ return 2;
14301831 \\}
1431 , ".tmp_source.zig:2:15: error: unable to infer expression type");
1832 ,
1833 ".tmp_source.zig:2:15: error: unable to infer expression type",
1834 );
14321835
1433 cases.add("atomic orderings of cmpxchg - failure stricter than success",
1836 cases.add(
1837 "atomic orderings of cmpxchg - failure stricter than success",
14341838 \\const AtomicOrder = @import("builtin").AtomicOrder;
14351839 \\export fn f() void {
14361840 \\ var x: i32 = 1234;
14371841 \\ while (!@cmpxchgWeak(i32, &x, 1234, 5678, AtomicOrder.Monotonic, AtomicOrder.SeqCst)) {}
14381842 \\}
1439 , ".tmp_source.zig:4:81: error: failure atomic ordering must be no stricter than success");
1843 ,
1844 ".tmp_source.zig:4:81: error: failure atomic ordering must be no stricter than success",
1845 );
14401846
1441 cases.add("atomic orderings of cmpxchg - success Monotonic or stricter",
1847 cases.add(
1848 "atomic orderings of cmpxchg - success Monotonic or stricter",
14421849 \\const AtomicOrder = @import("builtin").AtomicOrder;
14431850 \\export fn f() void {
14441851 \\ var x: i32 = 1234;
14451852 \\ while (!@cmpxchgWeak(i32, &x, 1234, 5678, AtomicOrder.Unordered, AtomicOrder.Unordered)) {}
14461853 \\}
1447 , ".tmp_source.zig:4:58: error: success atomic ordering must be Monotonic or stricter");
1854 ,
1855 ".tmp_source.zig:4:58: error: success atomic ordering must be Monotonic or stricter",
1856 );
14481857
1449 cases.add("negation overflow in function evaluation",
1858 cases.add(
1859 "negation overflow in function evaluation",
14501860 \\const y = neg(-128);
14511861 \\fn neg(x: i8) i8 {
14521862 \\ return -x;
......@@ -1454,10 +1864,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
14541864 \\
14551865 \\export fn entry() usize { return @sizeOf(@typeOf(y)); }
14561866 ,
1457 ".tmp_source.zig:3:12: error: negation caused overflow",
1458 ".tmp_source.zig:1:14: note: called from here");
1867 ".tmp_source.zig:3:12: error: negation caused overflow",
1868 ".tmp_source.zig:1:14: note: called from here",
1869 );
14591870
1460 cases.add("add overflow in function evaluation",
1871 cases.add(
1872 "add overflow in function evaluation",
14611873 \\const y = add(65530, 10);
14621874 \\fn add(a: u16, b: u16) u16 {
14631875 \\ return a + b;
......@@ -1465,11 +1877,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
14651877 \\
14661878 \\export fn entry() usize { return @sizeOf(@typeOf(y)); }
14671879 ,
1468 ".tmp_source.zig:3:14: error: operation caused overflow",
1469 ".tmp_source.zig:1:14: note: called from here");
1470
1880 ".tmp_source.zig:3:14: error: operation caused overflow",
1881 ".tmp_source.zig:1:14: note: called from here",
1882 );
14711883
1472 cases.add("sub overflow in function evaluation",
1884 cases.add(
1885 "sub overflow in function evaluation",
14731886 \\const y = sub(10, 20);
14741887 \\fn sub(a: u16, b: u16) u16 {
14751888 \\ return a - b;
......@@ -1477,10 +1890,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
14771890 \\
14781891 \\export fn entry() usize { return @sizeOf(@typeOf(y)); }
14791892 ,
1480 ".tmp_source.zig:3:14: error: operation caused overflow",
1481 ".tmp_source.zig:1:14: note: called from here");
1893 ".tmp_source.zig:3:14: error: operation caused overflow",
1894 ".tmp_source.zig:1:14: note: called from here",
1895 );
14821896
1483 cases.add("mul overflow in function evaluation",
1897 cases.add(
1898 "mul overflow in function evaluation",
14841899 \\const y = mul(300, 6000);
14851900 \\fn mul(a: u16, b: u16) u16 {
14861901 \\ return a * b;
......@@ -1488,27 +1903,34 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
14881903 \\
14891904 \\export fn entry() usize { return @sizeOf(@typeOf(y)); }
14901905 ,
1491 ".tmp_source.zig:3:14: error: operation caused overflow",
1492 ".tmp_source.zig:1:14: note: called from here");
1906 ".tmp_source.zig:3:14: error: operation caused overflow",
1907 ".tmp_source.zig:1:14: note: called from here",
1908 );
14931909
1494 cases.add("truncate sign mismatch",
1910 cases.add(
1911 "truncate sign mismatch",
14951912 \\fn f() i8 {
14961913 \\ const x: u32 = 10;
14971914 \\ return @truncate(i8, x);
14981915 \\}
14991916 \\
15001917 \\export fn entry() usize { return @sizeOf(@typeOf(f)); }
1501 , ".tmp_source.zig:3:26: error: expected signed integer type, found 'u32'");
1918 ,
1919 ".tmp_source.zig:3:26: error: expected signed integer type, found 'u32'",
1920 );
15021921
1503 cases.add("try in function with non error return type",
1922 cases.add(
1923 "try in function with non error return type",
15041924 \\export fn f() void {
15051925 \\ try something();
15061926 \\}
15071927 \\fn something() error!void { }
15081928 ,
1509 ".tmp_source.zig:2:5: error: expected type 'void', found 'error'");
1929 ".tmp_source.zig:2:5: error: expected type 'void', found 'error'",
1930 );
15101931
1511 cases.add("invalid pointer for var type",
1932 cases.add(
1933 "invalid pointer for var type",
15121934 \\extern fn ext() usize;
15131935 \\var bytes: [ext()]u8 = undefined;
15141936 \\export fn f() void {
......@@ -1516,30 +1938,42 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
15161938 \\ b.* = u8(i);
15171939 \\ }
15181940 \\}
1519 , ".tmp_source.zig:2:13: error: unable to evaluate constant expression");
1941 ,
1942 ".tmp_source.zig:2:13: error: unable to evaluate constant expression",
1943 );
15201944
1521 cases.add("export function with comptime parameter",
1945 cases.add(
1946 "export function with comptime parameter",
15221947 \\export fn foo(comptime x: i32, y: i32) i32{
15231948 \\ return x + y;
15241949 \\}
1525 , ".tmp_source.zig:1:15: error: comptime parameter not allowed in function with calling convention 'ccc'");
1950 ,
1951 ".tmp_source.zig:1:15: error: comptime parameter not allowed in function with calling convention 'ccc'",
1952 );
15261953
1527 cases.add("extern function with comptime parameter",
1954 cases.add(
1955 "extern function with comptime parameter",
15281956 \\extern fn foo(comptime x: i32, y: i32) i32;
15291957 \\fn f() i32 {
15301958 \\ return foo(1, 2);
15311959 \\}
15321960 \\export fn entry() usize { return @sizeOf(@typeOf(f)); }
1533 , ".tmp_source.zig:1:15: error: comptime parameter not allowed in function with calling convention 'ccc'");
1961 ,
1962 ".tmp_source.zig:1:15: error: comptime parameter not allowed in function with calling convention 'ccc'",
1963 );
15341964
1535 cases.add("convert fixed size array to slice with invalid size",
1965 cases.add(
1966 "convert fixed size array to slice with invalid size",
15361967 \\export fn f() void {
15371968 \\ var array: [5]u8 = undefined;
15381969 \\ var foo = ([]const u32)(array)[0];
15391970 \\}
1540 , ".tmp_source.zig:3:28: error: unable to convert [5]u8 to []const u32: size mismatch");
1971 ,
1972 ".tmp_source.zig:3:28: error: unable to convert [5]u8 to []const u32: size mismatch",
1973 );
15411974
1542 cases.add("non-pure function returns type",
1975 cases.add(
1976 "non-pure function returns type",
15431977 \\var a: u32 = 0;
15441978 \\pub fn List(comptime T: type) type {
15451979 \\ a += 1;
......@@ -1558,18 +1992,24 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
15581992 \\ var list: List(i32) = undefined;
15591993 \\ list.length = 10;
15601994 \\}
1561 , ".tmp_source.zig:3:7: error: unable to evaluate constant expression",
1562 ".tmp_source.zig:16:19: note: called from here");
1995 ,
1996 ".tmp_source.zig:3:7: error: unable to evaluate constant expression",
1997 ".tmp_source.zig:16:19: note: called from here",
1998 );
15631999
1564 cases.add("bogus method call on slice",
2000 cases.add(
2001 "bogus method call on slice",
15652002 \\var self = "aoeu";
15662003 \\fn f(m: []const u8) void {
15672004 \\ m.copy(u8, self[0..], m);
15682005 \\}
15692006 \\export fn entry() usize { return @sizeOf(@typeOf(f)); }
1570 , ".tmp_source.zig:3:6: error: no member named 'copy' in '[]const u8'");
2007 ,
2008 ".tmp_source.zig:3:6: error: no member named 'copy' in '[]const u8'",
2009 );
15712010
1572 cases.add("wrong number of arguments for method fn call",
2011 cases.add(
2012 "wrong number of arguments for method fn call",
15732013 \\const Foo = struct {
15742014 \\ fn method(self: &const Foo, a: i32) void {}
15752015 \\};
......@@ -1578,34 +2018,49 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
15782018 \\ foo.method(1, 2);
15792019 \\}
15802020 \\export fn entry() usize { return @sizeOf(@typeOf(f)); }
1581 , ".tmp_source.zig:6:15: error: expected 2 arguments, found 3");
2021 ,
2022 ".tmp_source.zig:6:15: error: expected 2 arguments, found 3",
2023 );
15822024
1583 cases.add("assign through constant pointer",
2025 cases.add(
2026 "assign through constant pointer",
15842027 \\export fn f() void {
15852028 \\ var cstr = c"Hat";
15862029 \\ cstr[0] = 'W';
15872030 \\}
1588 , ".tmp_source.zig:3:11: error: cannot assign to constant");
2031 ,
2032 ".tmp_source.zig:3:11: error: cannot assign to constant",
2033 );
15892034
1590 cases.add("assign through constant slice",
2035 cases.add(
2036 "assign through constant slice",
15912037 \\export fn f() void {
15922038 \\ var cstr: []const u8 = "Hat";
15932039 \\ cstr[0] = 'W';
15942040 \\}
1595 , ".tmp_source.zig:3:11: error: cannot assign to constant");
2041 ,
2042 ".tmp_source.zig:3:11: error: cannot assign to constant",
2043 );
15962044
1597 cases.add("main function with bogus args type",
2045 cases.add(
2046 "main function with bogus args type",
15982047 \\pub fn main(args: [][]bogus) !void {}
1599 , ".tmp_source.zig:1:23: error: use of undeclared identifier 'bogus'");
2048 ,
2049 ".tmp_source.zig:1:23: error: use of undeclared identifier 'bogus'",
2050 );
16002051
1601 cases.add("for loop missing element param",
2052 cases.add(
2053 "for loop missing element param",
16022054 \\fn foo(blah: []u8) void {
16032055 \\ for (blah) { }
16042056 \\}
16052057 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
1606 , ".tmp_source.zig:2:5: error: for loop expression missing element parameter");
2058 ,
2059 ".tmp_source.zig:2:5: error: for loop expression missing element parameter",
2060 );
16072061
1608 cases.add("misspelled type with pointer only reference",
2062 cases.add(
2063 "misspelled type with pointer only reference",
16092064 \\const JasonHM = u8;
16102065 \\const JasonList = &JsonNode;
16112066 \\
......@@ -1636,9 +2091,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
16362091 \\}
16372092 \\
16382093 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
1639 , ".tmp_source.zig:5:16: error: use of undeclared identifier 'JsonList'");
2094 ,
2095 ".tmp_source.zig:5:16: error: use of undeclared identifier 'JsonList'",
2096 );
16402097
1641 cases.add("method call with first arg type primitive",
2098 cases.add(
2099 "method call with first arg type primitive",
16422100 \\const Foo = struct {
16432101 \\ x: i32,
16442102 \\
......@@ -1654,9 +2112,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
16542112 \\
16552113 \\ derp.init();
16562114 \\}
1657 , ".tmp_source.zig:14:5: error: expected type 'i32', found '&const Foo'");
2115 ,
2116 ".tmp_source.zig:14:5: error: expected type 'i32', found '&const Foo'",
2117 );
16582118
1659 cases.add("method call with first arg type wrong container",
2119 cases.add(
2120 "method call with first arg type wrong container",
16602121 \\pub const List = struct {
16612122 \\ len: usize,
16622123 \\ allocator: &Allocator,
......@@ -1681,26 +2142,33 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
16812142 \\ var x = List.init(&global_allocator);
16822143 \\ x.init();
16832144 \\}
1684 , ".tmp_source.zig:23:5: error: expected type '&Allocator', found '&List'");
2145 ,
2146 ".tmp_source.zig:23:5: error: expected type '&Allocator', found '&List'",
2147 );
16852148
1686 cases.add("binary not on number literal",
2149 cases.add(
2150 "binary not on number literal",
16872151 \\const TINY_QUANTUM_SHIFT = 4;
16882152 \\const TINY_QUANTUM_SIZE = 1 << TINY_QUANTUM_SHIFT;
16892153 \\var block_aligned_stuff: usize = (4 + TINY_QUANTUM_SIZE) & ~(TINY_QUANTUM_SIZE - 1);
16902154 \\
16912155 \\export fn entry() usize { return @sizeOf(@typeOf(block_aligned_stuff)); }
1692 , ".tmp_source.zig:3:60: error: unable to perform binary not operation on type '(integer literal)'");
2156 ,
2157 ".tmp_source.zig:3:60: error: unable to perform binary not operation on type '(integer literal)'",
2158 );
16932159
16942160 cases.addCase(x: {
1695 const tc = cases.create("multiple files with private function error",
1696 \\const foo = @import("foo.zig");
2161 const tc = cases.create(
2162 "multiple files with private function error",
2163 \\const foo = @import("foo.zig",);
16972164 \\
16982165 \\export fn callPrivFunction() void {
16992166 \\ foo.privateFunction();
17002167 \\}
17012168 ,
17022169 ".tmp_source.zig:4:8: error: 'privateFunction' is private",
1703 "foo.zig:1:1: note: declared here");
2170 "foo.zig:1:1: note: declared here",
2171 );
17042172
17052173 tc.addSourceFile("foo.zig",
17062174 \\fn privateFunction() void { }
......@@ -1709,14 +2177,18 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
17092177 break :x tc;
17102178 });
17112179
1712 cases.add("container init with non-type",
2180 cases.add(
2181 "container init with non-type",
17132182 \\const zero: i32 = 0;
17142183 \\const a = zero{1};
17152184 \\
17162185 \\export fn entry() usize { return @sizeOf(@typeOf(a)); }
1717 , ".tmp_source.zig:2:11: error: expected type, found 'i32'");
2186 ,
2187 ".tmp_source.zig:2:11: error: expected type, found 'i32'",
2188 );
17182189
1719 cases.add("assign to constant field",
2190 cases.add(
2191 "assign to constant field",
17202192 \\const Foo = struct {
17212193 \\ field: i32,
17222194 \\};
......@@ -1724,9 +2196,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
17242196 \\ const f = Foo {.field = 1234,};
17252197 \\ f.field = 0;
17262198 \\}
1727 , ".tmp_source.zig:6:13: error: cannot assign to constant");
2199 ,
2200 ".tmp_source.zig:6:13: error: cannot assign to constant",
2201 );
17282202
1729 cases.add("return from defer expression",
2203 cases.add(
2204 "return from defer expression",
17302205 \\pub fn testTrickyDefer() !void {
17312206 \\ defer canFail() catch {};
17322207 \\
......@@ -1742,9 +2217,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
17422217 \\}
17432218 \\
17442219 \\export fn entry() usize { return @sizeOf(@typeOf(testTrickyDefer)); }
1745 , ".tmp_source.zig:4:11: error: cannot return from defer expression");
2220 ,
2221 ".tmp_source.zig:4:11: error: cannot return from defer expression",
2222 );
17462223
1747 cases.add("attempt to access var args out of bounds",
2224 cases.add(
2225 "attempt to access var args out of bounds",
17482226 \\fn add(args: ...) i32 {
17492227 \\ return args[0] + args[1];
17502228 \\}
......@@ -1755,10 +2233,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
17552233 \\
17562234 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
17572235 ,
1758 ".tmp_source.zig:2:26: error: index 1 outside argument list of size 1",
1759 ".tmp_source.zig:6:15: note: called from here");
2236 ".tmp_source.zig:2:26: error: index 1 outside argument list of size 1",
2237 ".tmp_source.zig:6:15: note: called from here",
2238 );
17602239
1761 cases.add("pass integer literal to var args",
2240 cases.add(
2241 "pass integer literal to var args",
17622242 \\fn add(args: ...) i32 {
17632243 \\ var sum = i32(0);
17642244 \\ {comptime var i: usize = 0; inline while (i < args.len) : (i += 1) {
......@@ -1772,32 +2252,44 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
17722252 \\}
17732253 \\
17742254 \\export fn entry() usize { return @sizeOf(@typeOf(bar)); }
1775 , ".tmp_source.zig:10:16: error: compiler bug: integer and float literals in var args function must be casted");
2255 ,
2256 ".tmp_source.zig:10:16: error: compiler bug: integer and float literals in var args function must be casted",
2257 );
17762258
1777 cases.add("assign too big number to u16",
2259 cases.add(
2260 "assign too big number to u16",
17782261 \\export fn foo() void {
17792262 \\ var vga_mem: u16 = 0xB8000;
17802263 \\}
1781 , ".tmp_source.zig:2:24: error: integer value 753664 cannot be implicitly casted to type 'u16'");
2264 ,
2265 ".tmp_source.zig:2:24: error: integer value 753664 cannot be implicitly casted to type 'u16'",
2266 );
17822267
1783 cases.add("global variable alignment non power of 2",
2268 cases.add(
2269 "global variable alignment non power of 2",
17842270 \\const some_data: [100]u8 align(3) = undefined;
17852271 \\export fn entry() usize { return @sizeOf(@typeOf(some_data)); }
1786 , ".tmp_source.zig:1:32: error: alignment value 3 is not a power of 2");
2272 ,
2273 ".tmp_source.zig:1:32: error: alignment value 3 is not a power of 2",
2274 );
17872275
1788 cases.add("function alignment non power of 2",
2276 cases.add(
2277 "function alignment non power of 2",
17892278 \\extern fn foo() align(3) void;
17902279 \\export fn entry() void { return foo(); }
1791 , ".tmp_source.zig:1:23: error: alignment value 3 is not a power of 2");
2280 ,
2281 ".tmp_source.zig:1:23: error: alignment value 3 is not a power of 2",
2282 );
17922283
1793 cases.add("compile log",
2284 cases.add(
2285 "compile log",
17942286 \\export fn foo() void {
1795 \\ comptime bar(12, "hi");
2287 \\ comptime bar(12, "hi",);
17962288 \\}
17972289 \\fn bar(a: i32, b: []const u8) void {
1798 \\ @compileLog("begin");
2290 \\ @compileLog("begin",);
17992291 \\ @compileLog("a", a, "b", b);
1800 \\ @compileLog("end");
2292 \\ @compileLog("end",);
18012293 \\}
18022294 ,
18032295 ".tmp_source.zig:5:5: error: found compile log statement",
......@@ -1805,9 +2297,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
18052297 ".tmp_source.zig:6:5: error: found compile log statement",
18062298 ".tmp_source.zig:2:17: note: called from here",
18072299 ".tmp_source.zig:7:5: error: found compile log statement",
1808 ".tmp_source.zig:2:17: note: called from here");
2300 ".tmp_source.zig:2:17: note: called from here",
2301 );
18092302
1810 cases.add("casting bit offset pointer to regular pointer",
2303 cases.add(
2304 "casting bit offset pointer to regular pointer",
18112305 \\const BitField = packed struct {
18122306 \\ a: u3,
18132307 \\ b: u3,
......@@ -1823,9 +2317,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
18232317 \\}
18242318 \\
18252319 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
1826 , ".tmp_source.zig:8:26: error: expected type '&const u3', found '&align(1:3:6) const u3'");
2320 ,
2321 ".tmp_source.zig:8:26: error: expected type '&const u3', found '&align(1:3:6) const u3'",
2322 );
18272323
1828 cases.add("referring to a struct that is invalid",
2324 cases.add(
2325 "referring to a struct that is invalid",
18292326 \\const UsbDeviceRequest = struct {
18302327 \\ Type: u8,
18312328 \\};
......@@ -1838,10 +2335,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
18382335 \\ if (!ok) unreachable;
18392336 \\}
18402337 ,
1841 ".tmp_source.zig:10:14: error: unable to evaluate constant expression",
1842 ".tmp_source.zig:6:20: note: called from here");
2338 ".tmp_source.zig:10:14: error: unable to evaluate constant expression",
2339 ".tmp_source.zig:6:20: note: called from here",
2340 );
18432341
1844 cases.add("control flow uses comptime var at runtime",
2342 cases.add(
2343 "control flow uses comptime var at runtime",
18452344 \\export fn foo() void {
18462345 \\ comptime var i = 0;
18472346 \\ while (i < 5) : (i += 1) {
......@@ -1851,55 +2350,78 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
18512350 \\
18522351 \\fn bar() void { }
18532352 ,
1854 ".tmp_source.zig:3:5: error: control flow attempts to use compile-time variable at runtime",
1855 ".tmp_source.zig:3:24: note: compile-time variable assigned here");
2353 ".tmp_source.zig:3:5: error: control flow attempts to use compile-time variable at runtime",
2354 ".tmp_source.zig:3:24: note: compile-time variable assigned here",
2355 );
18562356
1857 cases.add("ignored return value",
2357 cases.add(
2358 "ignored return value",
18582359 \\export fn foo() void {
18592360 \\ bar();
18602361 \\}
18612362 \\fn bar() i32 { return 0; }
1862 , ".tmp_source.zig:2:8: error: expression value is ignored");
2363 ,
2364 ".tmp_source.zig:2:8: error: expression value is ignored",
2365 );
18632366
1864 cases.add("ignored assert-err-ok return value",
2367 cases.add(
2368 "ignored assert-err-ok return value",
18652369 \\export fn foo() void {
18662370 \\ bar() catch unreachable;
18672371 \\}
18682372 \\fn bar() error!i32 { return 0; }
1869 , ".tmp_source.zig:2:11: error: expression value is ignored");
2373 ,
2374 ".tmp_source.zig:2:11: error: expression value is ignored",
2375 );
18702376
1871 cases.add("ignored statement value",
2377 cases.add(
2378 "ignored statement value",
18722379 \\export fn foo() void {
18732380 \\ 1;
18742381 \\}
1875 , ".tmp_source.zig:2:5: error: expression value is ignored");
2382 ,
2383 ".tmp_source.zig:2:5: error: expression value is ignored",
2384 );
18762385
1877 cases.add("ignored comptime statement value",
2386 cases.add(
2387 "ignored comptime statement value",
18782388 \\export fn foo() void {
18792389 \\ comptime {1;}
18802390 \\}
1881 , ".tmp_source.zig:2:15: error: expression value is ignored");
2391 ,
2392 ".tmp_source.zig:2:15: error: expression value is ignored",
2393 );
18822394
1883 cases.add("ignored comptime value",
2395 cases.add(
2396 "ignored comptime value",
18842397 \\export fn foo() void {
18852398 \\ comptime 1;
18862399 \\}
1887 , ".tmp_source.zig:2:5: error: expression value is ignored");
2400 ,
2401 ".tmp_source.zig:2:5: error: expression value is ignored",
2402 );
18882403
1889 cases.add("ignored defered statement value",
2404 cases.add(
2405 "ignored defered statement value",
18902406 \\export fn foo() void {
18912407 \\ defer {1;}
18922408 \\}
1893 , ".tmp_source.zig:2:12: error: expression value is ignored");
2409 ,
2410 ".tmp_source.zig:2:12: error: expression value is ignored",
2411 );
18942412
1895 cases.add("ignored defered function call",
2413 cases.add(
2414 "ignored defered function call",
18962415 \\export fn foo() void {
18972416 \\ defer bar();
18982417 \\}
18992418 \\fn bar() error!i32 { return 0; }
1900 , ".tmp_source.zig:2:14: error: expression value is ignored");
2419 ,
2420 ".tmp_source.zig:2:14: error: expression value is ignored",
2421 );
19012422
1902 cases.add("dereference an array",
2423 cases.add(
2424 "dereference an array",
19032425 \\var s_buffer: [10]u8 = undefined;
19042426 \\pub fn pass(in: []u8) []u8 {
19052427 \\ var out = &s_buffer;
......@@ -1908,11 +2430,14 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
19082430 \\}
19092431 \\
19102432 \\export fn entry() usize { return @sizeOf(@typeOf(pass)); }
1911 , ".tmp_source.zig:4:11: error: attempt to dereference non pointer type '[10]u8'");
2433 ,
2434 ".tmp_source.zig:4:11: error: attempt to dereference non pointer type '[10]u8'",
2435 );
19122436
1913 cases.add("pass const ptr to mutable ptr fn",
2437 cases.add(
2438 "pass const ptr to mutable ptr fn",
19142439 \\fn foo() bool {
1915 \\ const a = ([]const u8)("a");
2440 \\ const a = ([]const u8)("a",);
19162441 \\ const b = &a;
19172442 \\ return ptrEql(b, b);
19182443 \\}
......@@ -1921,18 +2446,22 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
19212446 \\}
19222447 \\
19232448 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
1924 , ".tmp_source.zig:4:19: error: expected type '&[]const u8', found '&const []const u8'");
2449 ,
2450 ".tmp_source.zig:4:19: error: expected type '&[]const u8', found '&const []const u8'",
2451 );
19252452
19262453 cases.addCase(x: {
1927 const tc = cases.create("export collision",
1928 \\const foo = @import("foo.zig");
2454 const tc = cases.create(
2455 "export collision",
2456 \\const foo = @import("foo.zig",);
19292457 \\
19302458 \\export fn bar() usize {
19312459 \\ return foo.baz;
19322460 \\}
19332461 ,
19342462 "foo.zig:1:8: error: exported symbol collision: 'bar'",
1935 ".tmp_source.zig:3:8: note: other symbol here");
2463 ".tmp_source.zig:3:8: note: other symbol here",
2464 );
19362465
19372466 tc.addSourceFile("foo.zig",
19382467 \\export fn bar() void {}
......@@ -1942,35 +2471,48 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
19422471 break :x tc;
19432472 });
19442473
1945 cases.add("pass non-copyable type by value to function",
2474 cases.add(
2475 "pass non-copyable type by value to function",
19462476 \\const Point = struct { x: i32, y: i32, };
19472477 \\fn foo(p: Point) void { }
19482478 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
1949 , ".tmp_source.zig:2:11: error: type 'Point' is not copyable; cannot pass by value");
2479 ,
2480 ".tmp_source.zig:2:11: error: type 'Point' is not copyable; cannot pass by value",
2481 );
19502482
1951 cases.add("implicit cast from array to mutable slice",
2483 cases.add(
2484 "implicit cast from array to mutable slice",
19522485 \\var global_array: [10]i32 = undefined;
19532486 \\fn foo(param: []i32) void {}
19542487 \\export fn entry() void {
19552488 \\ foo(global_array);
19562489 \\}
1957 , ".tmp_source.zig:4:9: error: expected type '[]i32', found '[10]i32'");
2490 ,
2491 ".tmp_source.zig:4:9: error: expected type '[]i32', found '[10]i32'",
2492 );
19582493
1959 cases.add("ptrcast to non-pointer",
2494 cases.add(
2495 "ptrcast to non-pointer",
19602496 \\export fn entry(a: &i32) usize {
19612497 \\ return @ptrCast(usize, a);
19622498 \\}
1963 , ".tmp_source.zig:2:21: error: expected pointer, found 'usize'");
2499 ,
2500 ".tmp_source.zig:2:21: error: expected pointer, found 'usize'",
2501 );
19642502
1965 cases.add("too many error values to cast to small integer",
2503 cases.add(
2504 "too many error values to cast to small integer",
19662505 \\const Error = error { A, B, C, D, E, F, G, H };
19672506 \\fn foo(e: Error) u2 {
19682507 \\ return u2(e);
19692508 \\}
19702509 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
1971 , ".tmp_source.zig:3:14: error: too many error values to fit in 'u2'");
2510 ,
2511 ".tmp_source.zig:3:14: error: too many error values to fit in 'u2'",
2512 );
19722513
1973 cases.add("asm at compile time",
2514 cases.add(
2515 "asm at compile time",
19742516 \\comptime {
19752517 \\ doSomeAsm();
19762518 \\}
......@@ -1982,48 +2524,66 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
19822524 \\ \\.set aoeu, derp;
19832525 \\ );
19842526 \\}
1985 , ".tmp_source.zig:6:5: error: unable to evaluate constant expression");
2527 ,
2528 ".tmp_source.zig:6:5: error: unable to evaluate constant expression",
2529 );
19862530
1987 cases.add("invalid member of builtin enum",
1988 \\const builtin = @import("builtin");
2531 cases.add(
2532 "invalid member of builtin enum",
2533 \\const builtin = @import("builtin",);
19892534 \\export fn entry() void {
19902535 \\ const foo = builtin.Arch.x86;
19912536 \\}
1992 , ".tmp_source.zig:3:29: error: container 'Arch' has no member called 'x86'");
2537 ,
2538 ".tmp_source.zig:3:29: error: container 'Arch' has no member called 'x86'",
2539 );
19932540
1994 cases.add("int to ptr of 0 bits",
2541 cases.add(
2542 "int to ptr of 0 bits",
19952543 \\export fn foo() void {
19962544 \\ var x: usize = 0x1000;
19972545 \\ var y: &void = @intToPtr(&void, x);
19982546 \\}
1999 , ".tmp_source.zig:3:31: error: type '&void' has 0 bits and cannot store information");
2547 ,
2548 ".tmp_source.zig:3:31: error: type '&void' has 0 bits and cannot store information",
2549 );
20002550
2001 cases.add("@fieldParentPtr - non struct",
2551 cases.add(
2552 "@fieldParentPtr - non struct",
20022553 \\const Foo = i32;
20032554 \\export fn foo(a: &i32) &Foo {
20042555 \\ return @fieldParentPtr(Foo, "a", a);
20052556 \\}
2006 , ".tmp_source.zig:3:28: error: expected struct type, found 'i32'");
2557 ,
2558 ".tmp_source.zig:3:28: error: expected struct type, found 'i32'",
2559 );
20072560
2008 cases.add("@fieldParentPtr - bad field name",
2561 cases.add(
2562 "@fieldParentPtr - bad field name",
20092563 \\const Foo = extern struct {
20102564 \\ derp: i32,
20112565 \\};
20122566 \\export fn foo(a: &i32) &Foo {
20132567 \\ return @fieldParentPtr(Foo, "a", a);
20142568 \\}
2015 , ".tmp_source.zig:5:33: error: struct 'Foo' has no field 'a'");
2569 ,
2570 ".tmp_source.zig:5:33: error: struct 'Foo' has no field 'a'",
2571 );
20162572
2017 cases.add("@fieldParentPtr - field pointer is not pointer",
2573 cases.add(
2574 "@fieldParentPtr - field pointer is not pointer",
20182575 \\const Foo = extern struct {
20192576 \\ a: i32,
20202577 \\};
20212578 \\export fn foo(a: i32) &Foo {
20222579 \\ return @fieldParentPtr(Foo, "a", a);
20232580 \\}
2024 , ".tmp_source.zig:5:38: error: expected pointer, found 'i32'");
2581 ,
2582 ".tmp_source.zig:5:38: error: expected pointer, found 'i32'",
2583 );
20252584
2026 cases.add("@fieldParentPtr - comptime field ptr not based on struct",
2585 cases.add(
2586 "@fieldParentPtr - comptime field ptr not based on struct",
20272587 \\const Foo = struct {
20282588 \\ a: i32,
20292589 \\ b: i32,
......@@ -2034,9 +2594,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
20342594 \\ const field_ptr = @intToPtr(&i32, 0x1234);
20352595 \\ const another_foo_ptr = @fieldParentPtr(Foo, "b", field_ptr);
20362596 \\}
2037 , ".tmp_source.zig:9:55: error: pointer value not based on parent struct");
2597 ,
2598 ".tmp_source.zig:9:55: error: pointer value not based on parent struct",
2599 );
20382600
2039 cases.add("@fieldParentPtr - comptime wrong field index",
2601 cases.add(
2602 "@fieldParentPtr - comptime wrong field index",
20402603 \\const Foo = struct {
20412604 \\ a: i32,
20422605 \\ b: i32,
......@@ -2046,76 +2609,100 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
20462609 \\comptime {
20472610 \\ const another_foo_ptr = @fieldParentPtr(Foo, "b", &foo.a);
20482611 \\}
2049 , ".tmp_source.zig:8:29: error: field 'b' has index 1 but pointer value is index 0 of struct 'Foo'");
2612 ,
2613 ".tmp_source.zig:8:29: error: field 'b' has index 1 but pointer value is index 0 of struct 'Foo'",
2614 );
20502615
2051 cases.add("@offsetOf - non struct",
2616 cases.add(
2617 "@offsetOf - non struct",
20522618 \\const Foo = i32;
20532619 \\export fn foo() usize {
2054 \\ return @offsetOf(Foo, "a");
2620 \\ return @offsetOf(Foo, "a",);
20552621 \\}
2056 , ".tmp_source.zig:3:22: error: expected struct type, found 'i32'");
2622 ,
2623 ".tmp_source.zig:3:22: error: expected struct type, found 'i32'",
2624 );
20572625
2058 cases.add("@offsetOf - bad field name",
2626 cases.add(
2627 "@offsetOf - bad field name",
20592628 \\const Foo = struct {
20602629 \\ derp: i32,
20612630 \\};
20622631 \\export fn foo() usize {
2063 \\ return @offsetOf(Foo, "a");
2632 \\ return @offsetOf(Foo, "a",);
20642633 \\}
2065 , ".tmp_source.zig:5:27: error: struct 'Foo' has no field 'a'");
2634 ,
2635 ".tmp_source.zig:5:27: error: struct 'Foo' has no field 'a'",
2636 );
20662637
2067 cases.addExe("missing main fn in executable",
2638 cases.addExe(
2639 "missing main fn in executable",
20682640 \\
2069 , "error: no member named 'main' in '");
2641 ,
2642 "error: no member named 'main' in '",
2643 );
20702644
2071 cases.addExe("private main fn",
2645 cases.addExe(
2646 "private main fn",
20722647 \\fn main() void {}
20732648 ,
20742649 "error: 'main' is private",
2075 ".tmp_source.zig:1:1: note: declared here");
2650 ".tmp_source.zig:1:1: note: declared here",
2651 );
20762652
2077 cases.add("setting a section on an extern variable",
2653 cases.add(
2654 "setting a section on an extern variable",
20782655 \\extern var foo: i32 section(".text2");
20792656 \\export fn entry() i32 {
20802657 \\ return foo;
20812658 \\}
20822659 ,
2083 ".tmp_source.zig:1:29: error: cannot set section of external variable 'foo'");
2660 ".tmp_source.zig:1:29: error: cannot set section of external variable 'foo'",
2661 );
20842662
2085 cases.add("setting a section on a local variable",
2663 cases.add(
2664 "setting a section on a local variable",
20862665 \\export fn entry() i32 {
20872666 \\ var foo: i32 section(".text2") = 1234;
20882667 \\ return foo;
20892668 \\}
20902669 ,
2091 ".tmp_source.zig:2:26: error: cannot set section of local variable 'foo'");
2670 ".tmp_source.zig:2:26: error: cannot set section of local variable 'foo'",
2671 );
20922672
2093 cases.add("setting a section on an extern fn",
2673 cases.add(
2674 "setting a section on an extern fn",
20942675 \\extern fn foo() section(".text2") void;
20952676 \\export fn entry() void {
20962677 \\ foo();
20972678 \\}
20982679 ,
2099 ".tmp_source.zig:1:25: error: cannot set section of external function 'foo'");
2680 ".tmp_source.zig:1:25: error: cannot set section of external function 'foo'",
2681 );
21002682
2101 cases.add("returning address of local variable - simple",
2683 cases.add(
2684 "returning address of local variable - simple",
21022685 \\export fn foo() &i32 {
21032686 \\ var a: i32 = undefined;
21042687 \\ return &a;
21052688 \\}
21062689 ,
2107 ".tmp_source.zig:3:13: error: function returns address of local variable");
2690 ".tmp_source.zig:3:13: error: function returns address of local variable",
2691 );
21082692
2109 cases.add("returning address of local variable - phi",
2693 cases.add(
2694 "returning address of local variable - phi",
21102695 \\export fn foo(c: bool) &i32 {
21112696 \\ var a: i32 = undefined;
21122697 \\ var b: i32 = undefined;
21132698 \\ return if (c) &a else &b;
21142699 \\}
21152700 ,
2116 ".tmp_source.zig:4:12: error: function returns address of local variable");
2701 ".tmp_source.zig:4:12: error: function returns address of local variable",
2702 );
21172703
2118 cases.add("inner struct member shadowing outer struct member",
2704 cases.add(
2705 "inner struct member shadowing outer struct member",
21192706 \\fn A() type {
21202707 \\ return struct {
21212708 \\ b: B(),
......@@ -2137,57 +2724,71 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
21372724 \\}
21382725 ,
21392726 ".tmp_source.zig:9:17: error: redefinition of 'Self'",
2140 ".tmp_source.zig:5:9: note: previous definition is here");
2727 ".tmp_source.zig:5:9: note: previous definition is here",
2728 );
21412729
2142 cases.add("while expected bool, got nullable",
2730 cases.add(
2731 "while expected bool, got nullable",
21432732 \\export fn foo() void {
21442733 \\ while (bar()) {}
21452734 \\}
21462735 \\fn bar() ?i32 { return 1; }
21472736 ,
2148 ".tmp_source.zig:2:15: error: expected type 'bool', found '?i32'");
2737 ".tmp_source.zig:2:15: error: expected type 'bool', found '?i32'",
2738 );
21492739
2150 cases.add("while expected bool, got error union",
2740 cases.add(
2741 "while expected bool, got error union",
21512742 \\export fn foo() void {
21522743 \\ while (bar()) {}
21532744 \\}
21542745 \\fn bar() error!i32 { return 1; }
21552746 ,
2156 ".tmp_source.zig:2:15: error: expected type 'bool', found 'error!i32'");
2747 ".tmp_source.zig:2:15: error: expected type 'bool', found 'error!i32'",
2748 );
21572749
2158 cases.add("while expected nullable, got bool",
2750 cases.add(
2751 "while expected nullable, got bool",
21592752 \\export fn foo() void {
21602753 \\ while (bar()) |x| {}
21612754 \\}
21622755 \\fn bar() bool { return true; }
21632756 ,
2164 ".tmp_source.zig:2:15: error: expected nullable type, found 'bool'");
2757 ".tmp_source.zig:2:15: error: expected nullable type, found 'bool'",
2758 );
21652759
2166 cases.add("while expected nullable, got error union",
2760 cases.add(
2761 "while expected nullable, got error union",
21672762 \\export fn foo() void {
21682763 \\ while (bar()) |x| {}
21692764 \\}
21702765 \\fn bar() error!i32 { return 1; }
21712766 ,
2172 ".tmp_source.zig:2:15: error: expected nullable type, found 'error!i32'");
2767 ".tmp_source.zig:2:15: error: expected nullable type, found 'error!i32'",
2768 );
21732769
2174 cases.add("while expected error union, got bool",
2770 cases.add(
2771 "while expected error union, got bool",
21752772 \\export fn foo() void {
21762773 \\ while (bar()) |x| {} else |err| {}
21772774 \\}
21782775 \\fn bar() bool { return true; }
21792776 ,
2180 ".tmp_source.zig:2:15: error: expected error union type, found 'bool'");
2777 ".tmp_source.zig:2:15: error: expected error union type, found 'bool'",
2778 );
21812779
2182 cases.add("while expected error union, got nullable",
2780 cases.add(
2781 "while expected error union, got nullable",
21832782 \\export fn foo() void {
21842783 \\ while (bar()) |x| {} else |err| {}
21852784 \\}
21862785 \\fn bar() ?i32 { return 1; }
21872786 ,
2188 ".tmp_source.zig:2:15: error: expected error union type, found '?i32'");
2787 ".tmp_source.zig:2:15: error: expected error union type, found '?i32'",
2788 );
21892789
2190 cases.add("inline fn calls itself indirectly",
2790 cases.add(
2791 "inline fn calls itself indirectly",
21912792 \\export fn foo() void {
21922793 \\ bar();
21932794 \\}
......@@ -2201,91 +2802,113 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
22012802 \\}
22022803 \\extern fn quux() void;
22032804 ,
2204 ".tmp_source.zig:4:8: error: unable to inline function");
2805 ".tmp_source.zig:4:8: error: unable to inline function",
2806 );
22052807
2206 cases.add("save reference to inline function",
2808 cases.add(
2809 "save reference to inline function",
22072810 \\export fn foo() void {
22082811 \\ quux(@ptrToInt(bar));
22092812 \\}
22102813 \\inline fn bar() void { }
22112814 \\extern fn quux(usize) void;
22122815 ,
2213 ".tmp_source.zig:4:8: error: unable to inline function");
2816 ".tmp_source.zig:4:8: error: unable to inline function",
2817 );
22142818
2215 cases.add("signed integer division",
2819 cases.add(
2820 "signed integer division",
22162821 \\export fn foo(a: i32, b: i32) i32 {
22172822 \\ return a / b;
22182823 \\}
22192824 ,
2220 ".tmp_source.zig:2:14: error: division with 'i32' and 'i32': signed integers must use @divTrunc, @divFloor, or @divExact");
2825 ".tmp_source.zig:2:14: error: division with 'i32' and 'i32': signed integers must use @divTrunc, @divFloor, or @divExact",
2826 );
22212827
2222 cases.add("signed integer remainder division",
2828 cases.add(
2829 "signed integer remainder division",
22232830 \\export fn foo(a: i32, b: i32) i32 {
22242831 \\ return a % b;
22252832 \\}
22262833 ,
2227 ".tmp_source.zig:2:14: error: remainder division with 'i32' and 'i32': signed integers and floats must use @rem or @mod");
2834 ".tmp_source.zig:2:14: error: remainder division with 'i32' and 'i32': signed integers and floats must use @rem or @mod",
2835 );
22282836
2229 cases.add("cast negative value to unsigned integer",
2837 cases.add(
2838 "cast negative value to unsigned integer",
22302839 \\comptime {
22312840 \\ const value: i32 = -1;
22322841 \\ const unsigned = u32(value);
22332842 \\}
22342843 ,
2235 ".tmp_source.zig:3:25: error: attempt to cast negative value to unsigned integer");
2844 ".tmp_source.zig:3:25: error: attempt to cast negative value to unsigned integer",
2845 );
22362846
2237 cases.add("compile-time division by zero",
2847 cases.add(
2848 "compile-time division by zero",
22382849 \\comptime {
22392850 \\ const a: i32 = 1;
22402851 \\ const b: i32 = 0;
22412852 \\ const c = a / b;
22422853 \\}
22432854 ,
2244 ".tmp_source.zig:4:17: error: division by zero");
2855 ".tmp_source.zig:4:17: error: division by zero",
2856 );
22452857
2246 cases.add("compile-time remainder division by zero",
2858 cases.add(
2859 "compile-time remainder division by zero",
22472860 \\comptime {
22482861 \\ const a: i32 = 1;
22492862 \\ const b: i32 = 0;
22502863 \\ const c = a % b;
22512864 \\}
22522865 ,
2253 ".tmp_source.zig:4:17: error: division by zero");
2866 ".tmp_source.zig:4:17: error: division by zero",
2867 );
22542868
2255 cases.add("compile-time integer cast truncates bits",
2869 cases.add(
2870 "compile-time integer cast truncates bits",
22562871 \\comptime {
22572872 \\ const spartan_count: u16 = 300;
22582873 \\ const byte = u8(spartan_count);
22592874 \\}
22602875 ,
2261 ".tmp_source.zig:3:20: error: cast from 'u16' to 'u8' truncates bits");
2876 ".tmp_source.zig:3:20: error: cast from 'u16' to 'u8' truncates bits",
2877 );
22622878
2263 cases.add("@setRuntimeSafety twice for same scope",
2879 cases.add(
2880 "@setRuntimeSafety twice for same scope",
22642881 \\export fn foo() void {
22652882 \\ @setRuntimeSafety(false);
22662883 \\ @setRuntimeSafety(false);
22672884 \\}
22682885 ,
22692886 ".tmp_source.zig:3:5: error: runtime safety set twice for same scope",
2270 ".tmp_source.zig:2:5: note: first set here");
2887 ".tmp_source.zig:2:5: note: first set here",
2888 );
22712889
2272 cases.add("@setFloatMode twice for same scope",
2890 cases.add(
2891 "@setFloatMode twice for same scope",
22732892 \\export fn foo() void {
22742893 \\ @setFloatMode(this, @import("builtin").FloatMode.Optimized);
22752894 \\ @setFloatMode(this, @import("builtin").FloatMode.Optimized);
22762895 \\}
22772896 ,
22782897 ".tmp_source.zig:3:5: error: float mode set twice for same scope",
2279 ".tmp_source.zig:2:5: note: first set here");
2898 ".tmp_source.zig:2:5: note: first set here",
2899 );
22802900
2281 cases.add("array access of type",
2901 cases.add(
2902 "array access of type",
22822903 \\export fn foo() void {
22832904 \\ var b: u8[40] = undefined;
22842905 \\}
22852906 ,
2286 ".tmp_source.zig:2:14: error: array access of non-array type 'type'");
2907 ".tmp_source.zig:2:14: error: array access of non-array type 'type'",
2908 );
22872909
2288 cases.add("cannot break out of defer expression",
2910 cases.add(
2911 "cannot break out of defer expression",
22892912 \\export fn foo() void {
22902913 \\ while (true) {
22912914 \\ defer {
......@@ -2294,9 +2917,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
22942917 \\ }
22952918 \\}
22962919 ,
2297 ".tmp_source.zig:4:13: error: cannot break out of defer expression");
2920 ".tmp_source.zig:4:13: error: cannot break out of defer expression",
2921 );
22982922
2299 cases.add("cannot continue out of defer expression",
2923 cases.add(
2924 "cannot continue out of defer expression",
23002925 \\export fn foo() void {
23012926 \\ while (true) {
23022927 \\ defer {
......@@ -2305,9 +2930,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
23052930 \\ }
23062931 \\}
23072932 ,
2308 ".tmp_source.zig:4:13: error: cannot continue out of defer expression");
2933 ".tmp_source.zig:4:13: error: cannot continue out of defer expression",
2934 );
23092935
2310 cases.add("calling a var args function only known at runtime",
2936 cases.add(
2937 "calling a var args function only known at runtime",
23112938 \\var foos = []fn(...) void { foo1, foo2 };
23122939 \\
23132940 \\fn foo1(args: ...) void {}
......@@ -2317,9 +2944,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
23172944 \\ foos[0]();
23182945 \\}
23192946 ,
2320 ".tmp_source.zig:7:9: error: calling a generic function requires compile-time known function value");
2947 ".tmp_source.zig:7:9: error: calling a generic function requires compile-time known function value",
2948 );
23212949
2322 cases.add("calling a generic function only known at runtime",
2950 cases.add(
2951 "calling a generic function only known at runtime",
23232952 \\var foos = []fn(var) void { foo1, foo2 };
23242953 \\
23252954 \\fn foo1(arg: var) void {}
......@@ -2329,10 +2958,12 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
23292958 \\ foos[0](true);
23302959 \\}
23312960 ,
2332 ".tmp_source.zig:7:9: error: calling a generic function requires compile-time known function value");
2961 ".tmp_source.zig:7:9: error: calling a generic function requires compile-time known function value",
2962 );
23332963
2334 cases.add("@compileError shows traceback of references that caused it",
2335 \\const foo = @compileError("aoeu");
2964 cases.add(
2965 "@compileError shows traceback of references that caused it",
2966 \\const foo = @compileError("aoeu",);
23362967 \\
23372968 \\const bar = baz + foo;
23382969 \\const baz = 1;
......@@ -2343,9 +2974,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
23432974 ,
23442975 ".tmp_source.zig:1:13: error: aoeu",
23452976 ".tmp_source.zig:3:19: note: referenced here",
2346 ".tmp_source.zig:7:12: note: referenced here");
2977 ".tmp_source.zig:7:12: note: referenced here",
2978 );
23472979
2348 cases.add("instantiating an undefined value for an invalid struct that contains itself",
2980 cases.add(
2981 "instantiating an undefined value for an invalid struct that contains itself",
23492982 \\const Foo = struct {
23502983 \\ x: Foo,
23512984 \\};
......@@ -2356,73 +2989,93 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
23562989 \\ return @sizeOf(@typeOf(foo.x));
23572990 \\}
23582991 ,
2359 ".tmp_source.zig:1:13: error: struct 'Foo' contains itself");
2992 ".tmp_source.zig:1:13: error: struct 'Foo' contains itself",
2993 );
23602994
2361 cases.add("float literal too large error",
2995 cases.add(
2996 "float literal too large error",
23622997 \\comptime {
23632998 \\ const a = 0x1.0p16384;
23642999 \\}
23653000 ,
2366 ".tmp_source.zig:2:15: error: float literal out of range of any type");
3001 ".tmp_source.zig:2:15: error: float literal out of range of any type",
3002 );
23673003
2368 cases.add("float literal too small error (denormal)",
3004 cases.add(
3005 "float literal too small error (denormal)",
23693006 \\comptime {
23703007 \\ const a = 0x1.0p-16384;
23713008 \\}
23723009 ,
2373 ".tmp_source.zig:2:15: error: float literal out of range of any type");
3010 ".tmp_source.zig:2:15: error: float literal out of range of any type",
3011 );
23743012
2375 cases.add("explicit cast float literal to integer when there is a fraction component",
3013 cases.add(
3014 "explicit cast float literal to integer when there is a fraction component",
23763015 \\export fn entry() i32 {
23773016 \\ return i32(12.34);
23783017 \\}
23793018 ,
2380 ".tmp_source.zig:2:16: error: fractional component prevents float value 12.340000 from being casted to type 'i32'");
3019 ".tmp_source.zig:2:16: error: fractional component prevents float value 12.340000 from being casted to type 'i32'",
3020 );
23813021
2382 cases.add("non pointer given to @ptrToInt",
3022 cases.add(
3023 "non pointer given to @ptrToInt",
23833024 \\export fn entry(x: i32) usize {
23843025 \\ return @ptrToInt(x);
23853026 \\}
23863027 ,
2387 ".tmp_source.zig:2:22: error: expected pointer, found 'i32'");
3028 ".tmp_source.zig:2:22: error: expected pointer, found 'i32'",
3029 );
23883030
2389 cases.add("@shlExact shifts out 1 bits",
3031 cases.add(
3032 "@shlExact shifts out 1 bits",
23903033 \\comptime {
23913034 \\ const x = @shlExact(u8(0b01010101), 2);
23923035 \\}
23933036 ,
2394 ".tmp_source.zig:2:15: error: operation caused overflow");
3037 ".tmp_source.zig:2:15: error: operation caused overflow",
3038 );
23953039
2396 cases.add("@shrExact shifts out 1 bits",
3040 cases.add(
3041 "@shrExact shifts out 1 bits",
23973042 \\comptime {
23983043 \\ const x = @shrExact(u8(0b10101010), 2);
23993044 \\}
24003045 ,
2401 ".tmp_source.zig:2:15: error: exact shift shifted out 1 bits");
3046 ".tmp_source.zig:2:15: error: exact shift shifted out 1 bits",
3047 );
24023048
2403 cases.add("shifting without int type or comptime known",
3049 cases.add(
3050 "shifting without int type or comptime known",
24043051 \\export fn entry(x: u8) u8 {
24053052 \\ return 0x11 << x;
24063053 \\}
24073054 ,
2408 ".tmp_source.zig:2:17: error: LHS of shift must be an integer type, or RHS must be compile-time known");
3055 ".tmp_source.zig:2:17: error: LHS of shift must be an integer type, or RHS must be compile-time known",
3056 );
24093057
2410 cases.add("shifting RHS is log2 of LHS int bit width",
3058 cases.add(
3059 "shifting RHS is log2 of LHS int bit width",
24113060 \\export fn entry(x: u8, y: u8) u8 {
24123061 \\ return x << y;
24133062 \\}
24143063 ,
2415 ".tmp_source.zig:2:17: error: expected type 'u3', found 'u8'");
3064 ".tmp_source.zig:2:17: error: expected type 'u3', found 'u8'",
3065 );
24163066
2417 cases.add("globally shadowing a primitive type",
3067 cases.add(
3068 "globally shadowing a primitive type",
24183069 \\const u16 = @intType(false, 8);
24193070 \\export fn entry() void {
24203071 \\ const a: u16 = 300;
24213072 \\}
24223073 ,
2423 ".tmp_source.zig:1:1: error: declaration shadows type 'u16'");
3074 ".tmp_source.zig:1:1: error: declaration shadows type 'u16'",
3075 );
24243076
2425 cases.add("implicitly increasing pointer alignment",
3077 cases.add(
3078 "implicitly increasing pointer alignment",
24263079 \\const Foo = packed struct {
24273080 \\ a: u8,
24283081 \\ b: u32,
......@@ -2437,9 +3090,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
24373090 \\ x.* += 1;
24383091 \\}
24393092 ,
2440 ".tmp_source.zig:8:13: error: expected type '&u32', found '&align(1) u32'");
3093 ".tmp_source.zig:8:13: error: expected type '&u32', found '&align(1) u32'",
3094 );
24413095
2442 cases.add("implicitly increasing slice alignment",
3096 cases.add(
3097 "implicitly increasing slice alignment",
24433098 \\const Foo = packed struct {
24443099 \\ a: u8,
24453100 \\ b: u32,
......@@ -2455,9 +3110,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
24553110 \\ x[0] += 1;
24563111 \\}
24573112 ,
2458 ".tmp_source.zig:9:17: error: expected type '[]u32', found '[]align(1) u32'");
3113 ".tmp_source.zig:9:17: error: expected type '[]u32', found '[]align(1) u32'",
3114 );
24593115
2460 cases.add("increase pointer alignment in @ptrCast",
3116 cases.add(
3117 "increase pointer alignment in @ptrCast",
24613118 \\export fn entry() u32 {
24623119 \\ var bytes: [4]u8 = []u8{0x01, 0x02, 0x03, 0x04};
24633120 \\ const ptr = @ptrCast(&u32, &bytes[0]);
......@@ -2466,9 +3123,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
24663123 ,
24673124 ".tmp_source.zig:3:17: error: cast increases pointer alignment",
24683125 ".tmp_source.zig:3:38: note: '&u8' has alignment 1",
2469 ".tmp_source.zig:3:27: note: '&u32' has alignment 4");
3126 ".tmp_source.zig:3:27: note: '&u32' has alignment 4",
3127 );
24703128
2471 cases.add("increase pointer alignment in slice resize",
3129 cases.add(
3130 "increase pointer alignment in slice resize",
24723131 \\export fn entry() u32 {
24733132 \\ var bytes = []u8{0x01, 0x02, 0x03, 0x04};
24743133 \\ return ([]u32)(bytes[0..])[0];
......@@ -2476,16 +3135,20 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
24763135 ,
24773136 ".tmp_source.zig:3:19: error: cast increases pointer alignment",
24783137 ".tmp_source.zig:3:19: note: '[]u8' has alignment 1",
2479 ".tmp_source.zig:3:19: note: '[]u32' has alignment 4");
3138 ".tmp_source.zig:3:19: note: '[]u32' has alignment 4",
3139 );
24803140
2481 cases.add("@alignCast expects pointer or slice",
3141 cases.add(
3142 "@alignCast expects pointer or slice",
24823143 \\export fn entry() void {
24833144 \\ @alignCast(4, u32(3));
24843145 \\}
24853146 ,
2486 ".tmp_source.zig:2:22: error: expected pointer or slice, found 'u32'");
3147 ".tmp_source.zig:2:22: error: expected pointer or slice, found 'u32'",
3148 );
24873149
2488 cases.add("passing an under-aligned function pointer",
3150 cases.add(
3151 "passing an under-aligned function pointer",
24893152 \\export fn entry() void {
24903153 \\ testImplicitlyDecreaseFnAlign(alignedSmall, 1234);
24913154 \\}
......@@ -2494,9 +3157,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
24943157 \\}
24953158 \\fn alignedSmall() align(4) i32 { return 1234; }
24963159 ,
2497 ".tmp_source.zig:2:35: error: expected type 'fn() align(8) i32', found 'fn() align(4) i32'");
3160 ".tmp_source.zig:2:35: error: expected type 'fn() align(8) i32', found 'fn() align(4) i32'",
3161 );
24983162
2499 cases.add("passing a not-aligned-enough pointer to cmpxchg",
3163 cases.add(
3164 "passing a not-aligned-enough pointer to cmpxchg",
25003165 \\const AtomicOrder = @import("builtin").AtomicOrder;
25013166 \\export fn entry() bool {
25023167 \\ var x: i32 align(1) = 1234;
......@@ -2504,16 +3169,20 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
25043169 \\ return x == 5678;
25053170 \\}
25063171 ,
2507 ".tmp_source.zig:4:32: error: expected type '&i32', found '&align(1) i32'");
3172 ".tmp_source.zig:4:32: error: expected type '&i32', found '&align(1) i32'",
3173 );
25083174
2509 cases.add("wrong size to an array literal",
3175 cases.add(
3176 "wrong size to an array literal",
25103177 \\comptime {
25113178 \\ const array = [2]u8{1, 2, 3};
25123179 \\}
25133180 ,
2514 ".tmp_source.zig:2:24: error: expected [2]u8 literal, found [3]u8 literal");
3181 ".tmp_source.zig:2:24: error: expected [2]u8 literal, found [3]u8 literal",
3182 );
25153183
2516 cases.add("@setEvalBranchQuota in non-root comptime execution context",
3184 cases.add(
3185 "@setEvalBranchQuota in non-root comptime execution context",
25173186 \\comptime {
25183187 \\ foo();
25193188 \\}
......@@ -2523,9 +3192,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
25233192 ,
25243193 ".tmp_source.zig:5:5: error: @setEvalBranchQuota must be called from the top of the comptime stack",
25253194 ".tmp_source.zig:2:8: note: called from here",
2526 ".tmp_source.zig:1:10: note: called from here");
3195 ".tmp_source.zig:1:10: note: called from here",
3196 );
25273197
2528 cases.add("wrong pointer implicitly casted to pointer to @OpaqueType()",
3198 cases.add(
3199 "wrong pointer implicitly casted to pointer to @OpaqueType()",
25293200 \\const Derp = @OpaqueType();
25303201 \\extern fn bar(d: &Derp) void;
25313202 \\export fn foo() void {
......@@ -2533,9 +3204,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
25333204 \\ bar(@ptrCast(&c_void, &x));
25343205 \\}
25353206 ,
2536 ".tmp_source.zig:5:9: error: expected type '&Derp', found '&c_void'");
3207 ".tmp_source.zig:5:9: error: expected type '&Derp', found '&c_void'",
3208 );
25373209
2538 cases.add("non-const variables of things that require const variables",
3210 cases.add(
3211 "non-const variables of things that require const variables",
25393212 \\const Opaque = @OpaqueType();
25403213 \\
25413214 \\export fn entry(opaque: &Opaque) void {
......@@ -2549,7 +3222,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
25493222 \\ var e = null;
25503223 \\ var f = opaque.*;
25513224 \\ var g = i32;
2552 \\ var h = @import("std");
3225 \\ var h = @import("std",);
25533226 \\ var i = (Foo {}).bar;
25543227 \\
25553228 \\ var z: noreturn = return;
......@@ -2569,26 +3242,32 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
25693242 ".tmp_source.zig:13:4: error: variable of type 'type' must be const or comptime",
25703243 ".tmp_source.zig:14:4: error: variable of type '(namespace)' must be const or comptime",
25713244 ".tmp_source.zig:15:4: error: variable of type '(bound fn(&const Foo) void)' must be const or comptime",
2572 ".tmp_source.zig:17:4: error: unreachable code");
3245 ".tmp_source.zig:17:4: error: unreachable code",
3246 );
25733247
2574 cases.add("wrong types given to atomic order args in cmpxchg",
3248 cases.add(
3249 "wrong types given to atomic order args in cmpxchg",
25753250 \\export fn entry() void {
25763251 \\ var x: i32 = 1234;
25773252 \\ while (!@cmpxchgWeak(i32, &x, 1234, 5678, u32(1234), u32(1234))) {}
25783253 \\}
25793254 ,
2580 ".tmp_source.zig:3:50: error: expected type 'AtomicOrder', found 'u32'");
3255 ".tmp_source.zig:3:50: error: expected type 'AtomicOrder', found 'u32'",
3256 );
25813257
2582 cases.add("wrong types given to @export",
3258 cases.add(
3259 "wrong types given to @export",
25833260 \\extern fn entry() void { }
25843261 \\comptime {
25853262 \\ @export("entry", entry, u32(1234));
25863263 \\}
25873264 ,
2588 ".tmp_source.zig:3:32: error: expected type 'GlobalLinkage', found 'u32'");
3265 ".tmp_source.zig:3:32: error: expected type 'GlobalLinkage', found 'u32'",
3266 );
25893267
2590 cases.add("struct with invalid field",
2591 \\const std = @import("std");
3268 cases.add(
3269 "struct with invalid field",
3270 \\const std = @import("std",);
25923271 \\const Allocator = std.mem.Allocator;
25933272 \\const ArrayList = std.ArrayList;
25943273 \\
......@@ -2612,23 +3291,29 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
26123291 \\ };
26133292 \\}
26143293 ,
2615 ".tmp_source.zig:14:17: error: use of undeclared identifier 'HeaderValue'");
3294 ".tmp_source.zig:14:17: error: use of undeclared identifier 'HeaderValue'",
3295 );
26163296
2617 cases.add("@setAlignStack outside function",
3297 cases.add(
3298 "@setAlignStack outside function",
26183299 \\comptime {
26193300 \\ @setAlignStack(16);
26203301 \\}
26213302 ,
2622 ".tmp_source.zig:2:5: error: @setAlignStack outside function");
3303 ".tmp_source.zig:2:5: error: @setAlignStack outside function",
3304 );
26233305
2624 cases.add("@setAlignStack in naked function",
3306 cases.add(
3307 "@setAlignStack in naked function",
26253308 \\export nakedcc fn entry() void {
26263309 \\ @setAlignStack(16);
26273310 \\}
26283311 ,
2629 ".tmp_source.zig:2:5: error: @setAlignStack in naked function");
3312 ".tmp_source.zig:2:5: error: @setAlignStack in naked function",
3313 );
26303314
2631 cases.add("@setAlignStack in inline function",
3315 cases.add(
3316 "@setAlignStack in inline function",
26323317 \\export fn entry() void {
26333318 \\ foo();
26343319 \\}
......@@ -2636,25 +3321,31 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
26363321 \\ @setAlignStack(16);
26373322 \\}
26383323 ,
2639 ".tmp_source.zig:5:5: error: @setAlignStack in inline function");
3324 ".tmp_source.zig:5:5: error: @setAlignStack in inline function",
3325 );
26403326
2641 cases.add("@setAlignStack set twice",
3327 cases.add(
3328 "@setAlignStack set twice",
26423329 \\export fn entry() void {
26433330 \\ @setAlignStack(16);
26443331 \\ @setAlignStack(16);
26453332 \\}
26463333 ,
26473334 ".tmp_source.zig:3:5: error: alignstack set twice",
2648 ".tmp_source.zig:2:5: note: first set here");
3335 ".tmp_source.zig:2:5: note: first set here",
3336 );
26493337
2650 cases.add("@setAlignStack too big",
3338 cases.add(
3339 "@setAlignStack too big",
26513340 \\export fn entry() void {
26523341 \\ @setAlignStack(511 + 1);
26533342 \\}
26543343 ,
2655 ".tmp_source.zig:2:5: error: attempt to @setAlignStack(512); maximum is 256");
3344 ".tmp_source.zig:2:5: error: attempt to @setAlignStack(512); maximum is 256",
3345 );
26563346
2657 cases.add("storing runtime value in compile time variable then using it",
3347 cases.add(
3348 "storing runtime value in compile time variable then using it",
26583349 \\const Mode = @import("builtin").Mode;
26593350 \\
26603351 \\fn Free(comptime filename: []const u8) TestCase {
......@@ -2697,9 +3388,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
26973388 \\ }
26983389 \\}
26993390 ,
2700 ".tmp_source.zig:37:16: error: cannot store runtime value in compile time variable");
3391 ".tmp_source.zig:37:16: error: cannot store runtime value in compile time variable",
3392 );
27013393
2702 cases.add("field access of opaque type",
3394 cases.add(
3395 "field access of opaque type",
27033396 \\const MyType = @OpaqueType();
27043397 \\
27053398 \\export fn entry() bool {
......@@ -2711,120 +3404,148 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
27113404 \\ return x.blah;
27123405 \\}
27133406 ,
2714 ".tmp_source.zig:9:13: error: type '&MyType' does not support field access");
3407 ".tmp_source.zig:9:13: error: type '&MyType' does not support field access",
3408 );
27153409
2716 cases.add("carriage return special case",
3410 cases.add(
3411 "carriage return special case",
27173412 "fn test() bool {\r\n" ++
2718 " true\r\n" ++
2719 "}\r\n"
2720 ,
2721 ".tmp_source.zig:1:17: error: invalid carriage return, only '\\n' line endings are supported");
2722
2723 cases.add("non-printable invalid character",
2724 "\xff\xfe" ++
2725 \\fn test() bool {\r
2726 \\ true\r
2727 \\}
2728 ,
2729 ".tmp_source.zig:1:1: error: invalid character: '\\xff'");
3413 " true\r\n" ++
3414 "}\r\n",
3415 ".tmp_source.zig:1:17: error: invalid carriage return, only '\\n' line endings are supported",
3416 );
3417
3418 cases.add(
3419 "non-printable invalid character",
3420 "\xff\xfe" ++
3421 \\fn test() bool {\r
3422 \\ true\r
3423 \\}
3424 ,
3425 ".tmp_source.zig:1:1: error: invalid character: '\\xff'",
3426 );
27303427
2731 cases.add("non-printable invalid character with escape alternative",
3428 cases.add(
3429 "non-printable invalid character with escape alternative",
27323430 "fn test() bool {\n" ++
2733 "\ttrue\n" ++
2734 "}\n"
2735 ,
2736 ".tmp_source.zig:2:1: error: invalid character: '\\t'");
3431 "\ttrue\n" ++
3432 "}\n",
3433 ".tmp_source.zig:2:1: error: invalid character: '\\t'",
3434 );
27373435
2738 cases.add("@ArgType given non function parameter",
3436 cases.add(
3437 "@ArgType given non function parameter",
27393438 \\comptime {
27403439 \\ _ = @ArgType(i32, 3);
27413440 \\}
27423441 ,
2743 ".tmp_source.zig:2:18: error: expected function, found 'i32'");
3442 ".tmp_source.zig:2:18: error: expected function, found 'i32'",
3443 );
27443444
2745 cases.add("@ArgType arg index out of bounds",
3445 cases.add(
3446 "@ArgType arg index out of bounds",
27463447 \\comptime {
27473448 \\ _ = @ArgType(@typeOf(add), 2);
27483449 \\}
27493450 \\fn add(a: i32, b: i32) i32 { return a + b; }
27503451 ,
2751 ".tmp_source.zig:2:32: error: arg index 2 out of bounds; 'fn(i32, i32) i32' has 2 arguments");
3452 ".tmp_source.zig:2:32: error: arg index 2 out of bounds; 'fn(i32, i32) i32' has 2 arguments",
3453 );
27523454
2753 cases.add("@memberType on unsupported type",
3455 cases.add(
3456 "@memberType on unsupported type",
27543457 \\comptime {
27553458 \\ _ = @memberType(i32, 0);
27563459 \\}
27573460 ,
2758 ".tmp_source.zig:2:21: error: type 'i32' does not support @memberType");
3461 ".tmp_source.zig:2:21: error: type 'i32' does not support @memberType",
3462 );
27593463
2760 cases.add("@memberType on enum",
3464 cases.add(
3465 "@memberType on enum",
27613466 \\comptime {
27623467 \\ _ = @memberType(Foo, 0);
27633468 \\}
27643469 \\const Foo = enum {A,};
27653470 ,
2766 ".tmp_source.zig:2:21: error: type 'Foo' does not support @memberType");
3471 ".tmp_source.zig:2:21: error: type 'Foo' does not support @memberType",
3472 );
27673473
2768 cases.add("@memberType struct out of bounds",
3474 cases.add(
3475 "@memberType struct out of bounds",
27693476 \\comptime {
27703477 \\ _ = @memberType(Foo, 0);
27713478 \\}
27723479 \\const Foo = struct {};
27733480 ,
2774 ".tmp_source.zig:2:26: error: member index 0 out of bounds; 'Foo' has 0 members");
3481 ".tmp_source.zig:2:26: error: member index 0 out of bounds; 'Foo' has 0 members",
3482 );
27753483
2776 cases.add("@memberType union out of bounds",
3484 cases.add(
3485 "@memberType union out of bounds",
27773486 \\comptime {
27783487 \\ _ = @memberType(Foo, 1);
27793488 \\}
27803489 \\const Foo = union {A: void,};
27813490 ,
2782 ".tmp_source.zig:2:26: error: member index 1 out of bounds; 'Foo' has 1 members");
3491 ".tmp_source.zig:2:26: error: member index 1 out of bounds; 'Foo' has 1 members",
3492 );
27833493
2784 cases.add("@memberName on unsupported type",
3494 cases.add(
3495 "@memberName on unsupported type",
27853496 \\comptime {
27863497 \\ _ = @memberName(i32, 0);
27873498 \\}
27883499 ,
2789 ".tmp_source.zig:2:21: error: type 'i32' does not support @memberName");
3500 ".tmp_source.zig:2:21: error: type 'i32' does not support @memberName",
3501 );
27903502
2791 cases.add("@memberName struct out of bounds",
3503 cases.add(
3504 "@memberName struct out of bounds",
27923505 \\comptime {
27933506 \\ _ = @memberName(Foo, 0);
27943507 \\}
27953508 \\const Foo = struct {};
27963509 ,
2797 ".tmp_source.zig:2:26: error: member index 0 out of bounds; 'Foo' has 0 members");
3510 ".tmp_source.zig:2:26: error: member index 0 out of bounds; 'Foo' has 0 members",
3511 );
27983512
2799 cases.add("@memberName enum out of bounds",
3513 cases.add(
3514 "@memberName enum out of bounds",
28003515 \\comptime {
28013516 \\ _ = @memberName(Foo, 1);
28023517 \\}
28033518 \\const Foo = enum {A,};
28043519 ,
2805 ".tmp_source.zig:2:26: error: member index 1 out of bounds; 'Foo' has 1 members");
3520 ".tmp_source.zig:2:26: error: member index 1 out of bounds; 'Foo' has 1 members",
3521 );
28063522
2807 cases.add("@memberName union out of bounds",
3523 cases.add(
3524 "@memberName union out of bounds",
28083525 \\comptime {
28093526 \\ _ = @memberName(Foo, 1);
28103527 \\}
28113528 \\const Foo = union {A:i32,};
28123529 ,
2813 ".tmp_source.zig:2:26: error: member index 1 out of bounds; 'Foo' has 1 members");
3530 ".tmp_source.zig:2:26: error: member index 1 out of bounds; 'Foo' has 1 members",
3531 );
28143532
2815 cases.add("calling var args extern function, passing array instead of pointer",
3533 cases.add(
3534 "calling var args extern function, passing array instead of pointer",
28163535 \\export fn entry() void {
2817 \\ foo("hello");
3536 \\ foo("hello",);
28183537 \\}
28193538 \\pub extern fn foo(format: &const u8, ...) void;
28203539 ,
2821 ".tmp_source.zig:2:9: error: expected type '&const u8', found '[5]u8'");
3540 ".tmp_source.zig:2:9: error: expected type '&const u8', found '[5]u8'",
3541 );
28223542
2823 cases.add("constant inside comptime function has compile error",
3543 cases.add(
3544 "constant inside comptime function has compile error",
28243545 \\const ContextAllocator = MemoryPool(usize);
28253546 \\
28263547 \\pub fn MemoryPool(comptime T: type) type {
2827 \\ const free_list_t = @compileError("aoeu");
3548 \\ const free_list_t = @compileError("aoeu",);
28283549 \\
28293550 \\ return struct {
28303551 \\ free_list: free_list_t,
......@@ -2837,9 +3558,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
28373558 ,
28383559 ".tmp_source.zig:4:25: error: aoeu",
28393560 ".tmp_source.zig:1:36: note: called from here",
2840 ".tmp_source.zig:12:20: note: referenced here");
3561 ".tmp_source.zig:12:20: note: referenced here",
3562 );
28413563
2842 cases.add("specify enum tag type that is too small",
3564 cases.add(
3565 "specify enum tag type that is too small",
28433566 \\const Small = enum (u2) {
28443567 \\ One,
28453568 \\ Two,
......@@ -2852,9 +3575,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
28523575 \\ var x = Small.One;
28533576 \\}
28543577 ,
2855 ".tmp_source.zig:1:20: error: 'u2' too small to hold all bits; must be at least 'u3'");
3578 ".tmp_source.zig:1:20: error: 'u2' too small to hold all bits; must be at least 'u3'",
3579 );
28563580
2857 cases.add("specify non-integer enum tag type",
3581 cases.add(
3582 "specify non-integer enum tag type",
28583583 \\const Small = enum (f32) {
28593584 \\ One,
28603585 \\ Two,
......@@ -2865,9 +3590,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
28653590 \\ var x = Small.One;
28663591 \\}
28673592 ,
2868 ".tmp_source.zig:1:20: error: expected integer, found 'f32'");
3593 ".tmp_source.zig:1:20: error: expected integer, found 'f32'",
3594 );
28693595
2870 cases.add("implicitly casting enum to tag type",
3596 cases.add(
3597 "implicitly casting enum to tag type",
28713598 \\const Small = enum(u2) {
28723599 \\ One,
28733600 \\ Two,
......@@ -2879,9 +3606,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
28793606 \\ var x: u2 = Small.Two;
28803607 \\}
28813608 ,
2882 ".tmp_source.zig:9:22: error: expected type 'u2', found 'Small'");
3609 ".tmp_source.zig:9:22: error: expected type 'u2', found 'Small'",
3610 );
28833611
2884 cases.add("explicitly casting enum to non tag type",
3612 cases.add(
3613 "explicitly casting enum to non tag type",
28853614 \\const Small = enum(u2) {
28863615 \\ One,
28873616 \\ Two,
......@@ -2893,9 +3622,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
28933622 \\ var x = u3(Small.Two);
28943623 \\}
28953624 ,
2896 ".tmp_source.zig:9:15: error: enum to integer cast to 'u3' instead of its tag type, 'u2'");
3625 ".tmp_source.zig:9:15: error: enum to integer cast to 'u3' instead of its tag type, 'u2'",
3626 );
28973627
2898 cases.add("explicitly casting non tag type to enum",
3628 cases.add(
3629 "explicitly casting non tag type to enum",
28993630 \\const Small = enum(u2) {
29003631 \\ One,
29013632 \\ Two,
......@@ -2908,9 +3639,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
29083639 \\ var x = Small(y);
29093640 \\}
29103641 ,
2911 ".tmp_source.zig:10:18: error: integer to enum cast from 'u3' instead of its tag type, 'u2'");
3642 ".tmp_source.zig:10:18: error: integer to enum cast from 'u3' instead of its tag type, 'u2'",
3643 );
29123644
2913 cases.add("non unsigned integer enum tag type",
3645 cases.add(
3646 "non unsigned integer enum tag type",
29143647 \\const Small = enum(i2) {
29153648 \\ One,
29163649 \\ Two,
......@@ -2922,9 +3655,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
29223655 \\ var y = Small.Two;
29233656 \\}
29243657 ,
2925 ".tmp_source.zig:1:19: error: expected unsigned integer, found 'i2'");
3658 ".tmp_source.zig:1:19: error: expected unsigned integer, found 'i2'",
3659 );
29263660
2927 cases.add("struct fields with value assignments",
3661 cases.add(
3662 "struct fields with value assignments",
29283663 \\const MultipleChoice = struct {
29293664 \\ A: i32 = 20,
29303665 \\};
......@@ -2932,9 +3667,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
29323667 \\ var x: MultipleChoice = undefined;
29333668 \\}
29343669 ,
2935 ".tmp_source.zig:2:14: error: enums, not structs, support field assignment");
3670 ".tmp_source.zig:2:14: error: enums, not structs, support field assignment",
3671 );
29363672
2937 cases.add("union fields with value assignments",
3673 cases.add(
3674 "union fields with value assignments",
29383675 \\const MultipleChoice = union {
29393676 \\ A: i32 = 20,
29403677 \\};
......@@ -2943,25 +3680,31 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
29433680 \\}
29443681 ,
29453682 ".tmp_source.zig:2:14: error: non-enum union field assignment",
2946 ".tmp_source.zig:1:24: note: consider 'union(enum)' here");
3683 ".tmp_source.zig:1:24: note: consider 'union(enum)' here",
3684 );
29473685
2948 cases.add("enum with 0 fields",
3686 cases.add(
3687 "enum with 0 fields",
29493688 \\const Foo = enum {};
29503689 \\export fn entry() usize {
29513690 \\ return @sizeOf(Foo);
29523691 \\}
29533692 ,
2954 ".tmp_source.zig:1:13: error: enums must have 1 or more fields");
3693 ".tmp_source.zig:1:13: error: enums must have 1 or more fields",
3694 );
29553695
2956 cases.add("union with 0 fields",
3696 cases.add(
3697 "union with 0 fields",
29573698 \\const Foo = union {};
29583699 \\export fn entry() usize {
29593700 \\ return @sizeOf(Foo);
29603701 \\}
29613702 ,
2962 ".tmp_source.zig:1:13: error: unions must have 1 or more fields");
3703 ".tmp_source.zig:1:13: error: unions must have 1 or more fields",
3704 );
29633705
2964 cases.add("enum value already taken",
3706 cases.add(
3707 "enum value already taken",
29653708 \\const MultipleChoice = enum(u32) {
29663709 \\ A = 20,
29673710 \\ B = 40,
......@@ -2974,9 +3717,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
29743717 \\}
29753718 ,
29763719 ".tmp_source.zig:6:9: error: enum tag value 60 already taken",
2977 ".tmp_source.zig:4:9: note: other occurrence here");
3720 ".tmp_source.zig:4:9: note: other occurrence here",
3721 );
29783722
2979 cases.add("union with specified enum omits field",
3723 cases.add(
3724 "union with specified enum omits field",
29803725 \\const Letter = enum {
29813726 \\ A,
29823727 \\ B,
......@@ -2991,9 +3736,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
29913736 \\}
29923737 ,
29933738 ".tmp_source.zig:6:17: error: enum field missing: 'C'",
2994 ".tmp_source.zig:4:5: note: declared here");
3739 ".tmp_source.zig:4:5: note: declared here",
3740 );
29953741
2996 cases.add("@TagType when union has no attached enum",
3742 cases.add(
3743 "@TagType when union has no attached enum",
29973744 \\const Foo = union {
29983745 \\ A: i32,
29993746 \\};
......@@ -3002,9 +3749,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
30023749 \\}
30033750 ,
30043751 ".tmp_source.zig:5:24: error: union 'Foo' has no tag",
3005 ".tmp_source.zig:1:13: note: consider 'union(enum)' here");
3752 ".tmp_source.zig:1:13: note: consider 'union(enum)' here",
3753 );
30063754
3007 cases.add("non-integer tag type to automatic union enum",
3755 cases.add(
3756 "non-integer tag type to automatic union enum",
30083757 \\const Foo = union(enum(f32)) {
30093758 \\ A: i32,
30103759 \\};
......@@ -3012,9 +3761,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
30123761 \\ const x = @TagType(Foo);
30133762 \\}
30143763 ,
3015 ".tmp_source.zig:1:23: error: expected integer tag type, found 'f32'");
3764 ".tmp_source.zig:1:23: error: expected integer tag type, found 'f32'",
3765 );
30163766
3017 cases.add("non-enum tag type passed to union",
3767 cases.add(
3768 "non-enum tag type passed to union",
30183769 \\const Foo = union(u32) {
30193770 \\ A: i32,
30203771 \\};
......@@ -3022,9 +3773,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
30223773 \\ const x = @TagType(Foo);
30233774 \\}
30243775 ,
3025 ".tmp_source.zig:1:18: error: expected enum tag type, found 'u32'");
3776 ".tmp_source.zig:1:18: error: expected enum tag type, found 'u32'",
3777 );
30263778
3027 cases.add("union auto-enum value already taken",
3779 cases.add(
3780 "union auto-enum value already taken",
30283781 \\const MultipleChoice = union(enum(u32)) {
30293782 \\ A = 20,
30303783 \\ B = 40,
......@@ -3037,9 +3790,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
30373790 \\}
30383791 ,
30393792 ".tmp_source.zig:6:9: error: enum tag value 60 already taken",
3040 ".tmp_source.zig:4:9: note: other occurrence here");
3793 ".tmp_source.zig:4:9: note: other occurrence here",
3794 );
30413795
3042 cases.add("union enum field does not match enum",
3796 cases.add(
3797 "union enum field does not match enum",
30433798 \\const Letter = enum {
30443799 \\ A,
30453800 \\ B,
......@@ -3056,9 +3811,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
30563811 \\}
30573812 ,
30583813 ".tmp_source.zig:10:5: error: enum field not found: 'D'",
3059 ".tmp_source.zig:1:16: note: enum declared here");
3814 ".tmp_source.zig:1:16: note: enum declared here",
3815 );
30603816
3061 cases.add("field type supplied in an enum",
3817 cases.add(
3818 "field type supplied in an enum",
30623819 \\const Letter = enum {
30633820 \\ A: void,
30643821 \\ B,
......@@ -3069,9 +3826,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
30693826 \\}
30703827 ,
30713828 ".tmp_source.zig:2:8: error: structs and unions, not enums, support field types",
3072 ".tmp_source.zig:1:16: note: consider 'union(enum)' here");
3829 ".tmp_source.zig:1:16: note: consider 'union(enum)' here",
3830 );
30733831
3074 cases.add("struct field missing type",
3832 cases.add(
3833 "struct field missing type",
30753834 \\const Letter = struct {
30763835 \\ A,
30773836 \\};
......@@ -3079,9 +3838,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
30793838 \\ var a = Letter { .A = {} };
30803839 \\}
30813840 ,
3082 ".tmp_source.zig:2:5: error: struct field missing type");
3841 ".tmp_source.zig:2:5: error: struct field missing type",
3842 );
30833843
3084 cases.add("extern union field missing type",
3844 cases.add(
3845 "extern union field missing type",
30853846 \\const Letter = extern union {
30863847 \\ A,
30873848 \\};
......@@ -3089,9 +3850,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
30893850 \\ var a = Letter { .A = {} };
30903851 \\}
30913852 ,
3092 ".tmp_source.zig:2:5: error: union field missing type");
3853 ".tmp_source.zig:2:5: error: union field missing type",
3854 );
30933855
3094 cases.add("extern union given enum tag type",
3856 cases.add(
3857 "extern union given enum tag type",
30953858 \\const Letter = enum {
30963859 \\ A,
30973860 \\ B,
......@@ -3106,9 +3869,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
31063869 \\ var a = Payload { .A = 1234 };
31073870 \\}
31083871 ,
3109 ".tmp_source.zig:6:29: error: extern union does not support enum tag type");
3872 ".tmp_source.zig:6:29: error: extern union does not support enum tag type",
3873 );
31103874
3111 cases.add("packed union given enum tag type",
3875 cases.add(
3876 "packed union given enum tag type",
31123877 \\const Letter = enum {
31133878 \\ A,
31143879 \\ B,
......@@ -3123,9 +3888,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
31233888 \\ var a = Payload { .A = 1234 };
31243889 \\}
31253890 ,
3126 ".tmp_source.zig:6:29: error: packed union does not support enum tag type");
3891 ".tmp_source.zig:6:29: error: packed union does not support enum tag type",
3892 );
31273893
3128 cases.add("switch on union with no attached enum",
3894 cases.add(
3895 "switch on union with no attached enum",
31293896 \\const Payload = union {
31303897 \\ A: i32,
31313898 \\ B: f64,
......@@ -3143,9 +3910,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
31433910 \\}
31443911 ,
31453912 ".tmp_source.zig:11:14: error: switch on union which has no attached enum",
3146 ".tmp_source.zig:1:17: note: consider 'union(enum)' here");
3913 ".tmp_source.zig:1:17: note: consider 'union(enum)' here",
3914 );
31473915
3148 cases.add("enum in field count range but not matching tag",
3916 cases.add(
3917 "enum in field count range but not matching tag",
31493918 \\const Foo = enum(u32) {
31503919 \\ A = 10,
31513920 \\ B = 11,
......@@ -3155,9 +3924,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
31553924 \\}
31563925 ,
31573926 ".tmp_source.zig:6:16: error: enum 'Foo' has no tag matching integer value 0",
3158 ".tmp_source.zig:1:13: note: 'Foo' declared here");
3927 ".tmp_source.zig:1:13: note: 'Foo' declared here",
3928 );
31593929
3160 cases.add("comptime cast enum to union but field has payload",
3930 cases.add(
3931 "comptime cast enum to union but field has payload",
31613932 \\const Letter = enum { A, B, C };
31623933 \\const Value = union(Letter) {
31633934 \\ A: i32,
......@@ -3169,9 +3940,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
31693940 \\}
31703941 ,
31713942 ".tmp_source.zig:8:26: error: cast to union 'Value' must initialize 'i32' field 'A'",
3172 ".tmp_source.zig:3:5: note: field 'A' declared here");
3943 ".tmp_source.zig:3:5: note: field 'A' declared here",
3944 );
31733945
3174 cases.add("runtime cast to union which has non-void fields",
3946 cases.add(
3947 "runtime cast to union which has non-void fields",
31753948 \\const Letter = enum { A, B, C };
31763949 \\const Value = union(Letter) {
31773950 \\ A: i32,
......@@ -3186,9 +3959,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
31863959 \\}
31873960 ,
31883961 ".tmp_source.zig:11:20: error: runtime cast to union 'Value' which has non-void fields",
3189 ".tmp_source.zig:3:5: note: field 'A' has type 'i32'");
3962 ".tmp_source.zig:3:5: note: field 'A' has type 'i32'",
3963 );
31903964
3191 cases.add("self-referencing function pointer field",
3965 cases.add(
3966 "self-referencing function pointer field",
31923967 \\const S = struct {
31933968 \\ f: fn(_: S) void,
31943969 \\};
......@@ -3198,19 +3973,23 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
31983973 \\ var _ = S { .f = f };
31993974 \\}
32003975 ,
3201 ".tmp_source.zig:4:9: error: type 'S' is not copyable; cannot pass by value");
3976 ".tmp_source.zig:4:9: error: type 'S' is not copyable; cannot pass by value",
3977 );
32023978
3203 cases.add("taking offset of void field in struct",
3979 cases.add(
3980 "taking offset of void field in struct",
32043981 \\const Empty = struct {
32053982 \\ val: void,
32063983 \\};
32073984 \\export fn foo() void {
3208 \\ const fieldOffset = @offsetOf(Empty, "val");
3985 \\ const fieldOffset = @offsetOf(Empty, "val",);
32093986 \\}
32103987 ,
3211 ".tmp_source.zig:5:42: error: zero-bit field 'val' in struct 'Empty' has no offset");
3988 ".tmp_source.zig:5:42: error: zero-bit field 'val' in struct 'Empty' has no offset",
3989 );
32123990
3213 cases.add("invalid union field access in comptime",
3991 cases.add(
3992 "invalid union field access in comptime",
32143993 \\const Foo = union {
32153994 \\ Bar: u8,
32163995 \\ Baz: void,
......@@ -3220,21 +3999,26 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
32203999 \\ const bar_val = foo.Bar;
32214000 \\}
32224001 ,
3223 ".tmp_source.zig:7:24: error: accessing union field 'Bar' while field 'Baz' is set");
4002 ".tmp_source.zig:7:24: error: accessing union field 'Bar' while field 'Baz' is set",
4003 );
32244004
3225 cases.add("getting return type of generic function",
4005 cases.add(
4006 "getting return type of generic function",
32264007 \\fn generic(a: var) void {}
32274008 \\comptime {
32284009 \\ _ = @typeOf(generic).ReturnType;
32294010 \\}
32304011 ,
3231 ".tmp_source.zig:3:25: error: ReturnType has not been resolved because 'fn(var)var' is generic");
4012 ".tmp_source.zig:3:25: error: ReturnType has not been resolved because 'fn(var)var' is generic",
4013 );
32324014
3233 cases.add("getting @ArgType of generic function",
4015 cases.add(
4016 "getting @ArgType of generic function",
32344017 \\fn generic(a: var) void {}
32354018 \\comptime {
32364019 \\ _ = @ArgType(@typeOf(generic), 0);
32374020 \\}
32384021 ,
3239 ".tmp_source.zig:3:36: error: @ArgType could not resolve the type of arg 0 because 'fn(var)var' is generic");
4022 ".tmp_source.zig:3:36: error: @ArgType could not resolve the type of arg 0 because 'fn(var)var' is generic",
4023 );
32404024}
test/gen_h.zig-1
......@@ -76,5 +76,4 @@ pub fn addCases(cases: &tests.GenHContext) void {
7676 \\TEST_EXPORT void entry(struct Foo foo, uint8_t bar[]);
7777 \\
7878 );
79
8079}
test/standalone/brace_expansion/main.zig+4-9
......@@ -29,8 +29,7 @@ fn tokenize(input: []const u8) !ArrayList(Token) {
2929 for (input) |b, i| {
3030 switch (state) {
3131 State.Start => switch (b) {
32 'a' ... 'z',
33 'A' ... 'Z' => {
32 'a'...'z', 'A'...'Z' => {
3433 state = State.Word;
3534 tok_begin = i;
3635 },
......@@ -40,11 +39,8 @@ fn tokenize(input: []const u8) !ArrayList(Token) {
4039 else => return error.InvalidInput,
4140 },
4241 State.Word => switch (b) {
43 'a' ... 'z',
44 'A' ... 'Z' => {},
45 '{',
46 '}',
47 ',' => {
42 'a'...'z', 'A'...'Z' => {},
43 '{', '}', ',' => {
4844 try token_list.append(Token{ .Word = input[tok_begin..i] });
4945 switch (b) {
5046 '{' => try token_list.append(Token.OpenBrace),
......@@ -103,8 +99,7 @@ fn parse(tokens: &const ArrayList(Token), token_index: &usize) ParseError!Node {
10399 };
104100
105101 switch (tokens.items[token_index.*]) {
106 Token.Word,
107 Token.OpenBrace => {
102 Token.Word, Token.OpenBrace => {
108103 const pair = try global_allocator.alloc(Node, 2);
109104 pair[0] = result_node;
110105 pair[1] = try parse(tokens, token_index);
test/standalone/issue_339/test.zig+4-1
......@@ -1,5 +1,8 @@
11const StackTrace = @import("builtin").StackTrace;
2pub fn panic(msg: []const u8, stack_trace: ?&StackTrace) noreturn { @breakpoint(); while (true) {} }
2pub fn panic(msg: []const u8, stack_trace: ?&StackTrace) noreturn {
3 @breakpoint();
4 while (true) {}
5}
36
47fn bar() error!void {}
58
test/standalone/pkg_import/pkg.zig+3-1
......@@ -1 +1,3 @@
1pub fn add(a: i32, b: i32) i32 { return a + b; }
1pub fn add(a: i32, b: i32) i32 {
2 return a + b;
3}
test/standalone/use_alias/main.zig+1-1
......@@ -2,7 +2,7 @@ const c = @import("c.zig");
22const assert = @import("std").debug.assert;
33
44test "symbol exists" {
5 var foo = c.Foo {
5 var foo = c.Foo{
66 .a = 1,
77 .b = 1,
88 };
test/translate_c.zig+24-25
......@@ -638,7 +638,6 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
638638 \\}
639639 );
640640
641
642641 cases.addC("c style cast",
643642 \\int float_to_int(float a) {
644643 \\ return (int)a;
......@@ -1289,29 +1288,29 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
12891288 \\ }
12901289 \\}
12911290 ,
1292 \\pub fn switch_fn(i: c_int) c_int {
1293 \\ var res: c_int = 0;
1294 \\ __switch: {
1295 \\ __case_2: {
1296 \\ __default: {
1297 \\ __case_1: {
1298 \\ __case_0: {
1299 \\ switch (i) {
1300 \\ 0 => break :__case_0,
1301 \\ 1 => break :__case_1,
1302 \\ else => break :__default,
1303 \\ 2 => break :__case_2,
1304 \\ }
1305 \\ }
1306 \\ res = 1;
1307 \\ }
1308 \\ res = 2;
1309 \\ }
1310 \\ res = (3 * i);
1311 \\ break :__switch;
1312 \\ }
1313 \\ res = 5;
1314 \\ }
1315 \\}
1291 \\pub fn switch_fn(i: c_int) c_int {
1292 \\ var res: c_int = 0;
1293 \\ __switch: {
1294 \\ __case_2: {
1295 \\ __default: {
1296 \\ __case_1: {
1297 \\ __case_0: {
1298 \\ switch (i) {
1299 \\ 0 => break :__case_0,
1300 \\ 1 => break :__case_1,
1301 \\ else => break :__default,
1302 \\ 2 => break :__case_2,
1303 \\ }
1304 \\ }
1305 \\ res = 1;
1306 \\ }
1307 \\ res = 2;
1308 \\ }
1309 \\ res = (3 * i);
1310 \\ break :__switch;
1311 \\ }
1312 \\ res = 5;
1313 \\ }
1314 \\}
13161315 );
13171316}