authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-01-24 22:53:00-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-01-24 22:53:00-07:00
logbcb18338cd15dfd7a4e3e80e74d1fe395870fa48
treed44e1166bc509300c1dc39817aa9b9362732945f
parent29a83f648b8f0b6f757e07e3b1a6e15e8764b670

update std lib to use error type and global variables


10 files changed, 296 insertions(+), 303 deletions(-)

example/guess_number/main.zig+11-23
......@@ -3,45 +3,33 @@ export executable "guess_number";
33import "std.zig";
44import "rand.zig";
55
6error GetRandomFail;
7error ReadInputFail;
8
96pub fn main(args: [][]u8) %void => {
10 print_str("Welcome to the Guess Number Game in Zig.\n");
7 stderr.print_str("Welcome to the Guess Number Game in Zig.\n");
118
129 var seed : u32;
13 const seed_bytes = (&u8)(&seed)[0...@sizeof(u32)];
14 const err = os_get_random_bytes(seed_bytes);
15 if (err != @sizeof(u32)) {
16 // TODO full error message
17 fprint_str(stderr_fileno, "unable to get random bytes\n");
18 return error.GetRandomFail;
19 }
10 const seed_bytes = (&u8)(&seed)[0...4];
11 os_get_random_bytes(seed_bytes);
2012
2113 var rand = rand_new(seed);
2214
2315 const answer = rand.range_u64(0, 100) + 1;
2416
2517 while (true) {
26 print_str("\nGuess a number between 1 and 100: ");
18 stderr.print_str("\nGuess a number between 1 and 100: ");
2719 var line_buf : [20]u8;
28 var line_len : isize;
29 // TODO fix this awkward error handling
30 if (readline(line_buf, &line_len) || line_len == line_buf.len) {
31 // TODO full error message
32 fprint_str(stderr_fileno, "unable to read input\n");
33 return error.ReadInputFail;
34 }
20
21 // TODO print error message instead of returning
22 const line_len = %return stdin.readline(line_buf);
3523
3624 var guess : u64;
3725 if (parse_u64(line_buf[0...line_len - 1], 10, &guess)) {
38 print_str("Invalid number format.\n");
26 stderr.print_str("Invalid number format.\n");
3927 } else if (guess > answer) {
40 print_str("Guess lower.\n");
28 stderr.print_str("Guess lower.\n");
4129 } else if (guess < answer) {
42 print_str("Guess higher.\n");
30 stderr.print_str("Guess higher.\n");
4331 } else {
44 print_str("You win!\n");
32 stderr.print_str("You win!\n");
4533 return;
4634 }
4735 }
example/hello_world/hello.zig+1-2
......@@ -3,6 +3,5 @@ export executable "hello";
33import "std.zig";
44
55pub fn main(args: [][]u8) %void => {
6 //stderr.print_str("Hello, world!\n");
7 print_str("Hello, world!\n");
6 stdout.printf("Hello, world!\n");
87}
example/multiple_files/foo.zig+1-1
......@@ -3,7 +3,7 @@ import "std.zig";
33// purposefully conflicting function with main.zig
44// but it's private so it should be OK
55fn private_function() => {
6 print_str("OK 1\n");
6 stdout.printf("OK 1\n");
77}
88
99pub fn print_text() => {
example/multiple_files/main.zig+1-1
......@@ -5,7 +5,7 @@ import "foo.zig";
55
66pub fn main(args: [][]u8) i32 => {
77 private_function();
8 print_str("OK 2\n");
8 stdout.printf("OK 2\n");
99 return 0;
1010}
1111
example/shared_library/mathtest.zig+3-3
......@@ -1,10 +1,10 @@
11#version("2.0.0")
22export library "mathtest";
33
4export fn add(a: i32, b: i32) -> i32 {
4export fn add(a: i32, b: i32) i32 => {
55 a + b
66}
77
8export fn hang() -> unreachable {
9entry: goto entry;
8export fn hang() unreachable => {
9 while (true) { }
1010}
src/analyze.cpp+4
......@@ -3058,6 +3058,7 @@ static TypeTableEntry *analyze_cast_expr(CodeGen *g, ImportTableEntry *import, B
30583058 if (wanted_type->id == TypeTableEntryIdMaybe) {
30593059 if (types_match_const_cast_only(wanted_type->data.maybe.child_type, actual_type)) {
30603060 node->data.fn_call_expr.cast_op = CastOpMaybeWrap;
3061 context->cast_alloca_list.append(node);
30613062 eval_const_expr_implicit_cast(g, node, expr_node);
30623063 return wanted_type;
30633064 } else if (actual_type->id == TypeTableEntryIdNumLitInt ||
......@@ -3065,6 +3066,7 @@ static TypeTableEntry *analyze_cast_expr(CodeGen *g, ImportTableEntry *import, B
30653066 {
30663067 if (num_lit_fits_in_other_type(g, expr_node, wanted_type->data.maybe.child_type)) {
30673068 node->data.fn_call_expr.cast_op = CastOpMaybeWrap;
3069 context->cast_alloca_list.append(node);
30683070 eval_const_expr_implicit_cast(g, node, expr_node);
30693071 return wanted_type;
30703072 } else {
......@@ -3077,6 +3079,7 @@ static TypeTableEntry *analyze_cast_expr(CodeGen *g, ImportTableEntry *import, B
30773079 if (wanted_type->id == TypeTableEntryIdErrorUnion) {
30783080 if (types_match_const_cast_only(wanted_type->data.error.child_type, actual_type)) {
30793081 node->data.fn_call_expr.cast_op = CastOpErrorWrap;
3082 context->cast_alloca_list.append(node);
30803083 eval_const_expr_implicit_cast(g, node, expr_node);
30813084 return wanted_type;
30823085 } else if (actual_type->id == TypeTableEntryIdNumLitInt ||
......@@ -3084,6 +3087,7 @@ static TypeTableEntry *analyze_cast_expr(CodeGen *g, ImportTableEntry *import, B
30843087 {
30853088 if (num_lit_fits_in_other_type(g, expr_node, wanted_type->data.error.child_type)) {
30863089 node->data.fn_call_expr.cast_op = CastOpErrorWrap;
3090 context->cast_alloca_list.append(node);
30873091 eval_const_expr_implicit_cast(g, node, expr_node);
30883092 return wanted_type;
30893093 } else {
src/codegen.cpp+32-11
......@@ -325,11 +325,28 @@ static LLVMValueRef gen_cast_expr(CodeGen *g, AstNode *node) {
325325 return cast_expr->tmp_ptr;
326326 }
327327 case CastOpErrorWrap:
328 assert(wanted_type->id == TypeTableEntryIdErrorUnion);
329 if (wanted_type->data.error.child_type->size_in_bits == 0) {
330 return LLVMConstNull(g->err_tag_type->type_ref);
331 } else {
332 zig_panic("TODO");
328 {
329 assert(wanted_type->id == TypeTableEntryIdErrorUnion);
330 TypeTableEntry *child_type = wanted_type->data.error.child_type;
331 LLVMValueRef ok_err_val = LLVMConstNull(g->err_tag_type->type_ref);
332
333 if (child_type->size_in_bits == 0) {
334 return ok_err_val;
335 } else {
336 assert(cast_expr->tmp_ptr);
337 assert(wanted_type->id == TypeTableEntryIdErrorUnion);
338 assert(actual_type);
339
340 add_debug_source_node(g, node);
341 LLVMValueRef err_tag_ptr = LLVMBuildStructGEP(g->builder, cast_expr->tmp_ptr, 0, "");
342 LLVMBuildStore(g->builder, ok_err_val, err_tag_ptr);
343
344 LLVMValueRef payload_ptr = LLVMBuildStructGEP(g->builder, cast_expr->tmp_ptr, 1, "");
345 gen_assign_raw(g, node, BinOpTypeAssign,
346 payload_ptr, expr_val, child_type, actual_type);
347
348 return cast_expr->tmp_ptr;
349 }
333350 }
334351 case CastOpPureErrorWrap:
335352 assert(wanted_type->id == TypeTableEntryIdErrorUnion);
......@@ -1286,12 +1303,16 @@ static LLVMValueRef gen_return_expr(CodeGen *g, AstNode *node) {
12861303 if (return_type->id == TypeTableEntryIdPureError) {
12871304 gen_return(g, node, err_val);
12881305 } else if (return_type->id == TypeTableEntryIdErrorUnion) {
1289 assert(g->cur_ret_ptr);
1306 if (return_type->data.error.child_type->size_in_bits > 0) {
1307 assert(g->cur_ret_ptr);
12901308
1291 add_debug_source_node(g, node);
1292 LLVMValueRef tag_ptr = LLVMBuildStructGEP(g->builder, g->cur_ret_ptr, 0, "");
1293 LLVMBuildStore(g->builder, err_val, tag_ptr);
1294 LLVMBuildRetVoid(g->builder);
1309 add_debug_source_node(g, node);
1310 LLVMValueRef tag_ptr = LLVMBuildStructGEP(g->builder, g->cur_ret_ptr, 0, "");
1311 LLVMBuildStore(g->builder, err_val, tag_ptr);
1312 LLVMBuildRetVoid(g->builder);
1313 } else {
1314 gen_return(g, node, err_val);
1315 }
12951316 } else {
12961317 zig_unreachable();
12971318 }
......@@ -2011,7 +2032,7 @@ static LLVMValueRef gen_switch_expr(CodeGen *g, AstNode *node) {
20112032 LLVMPositionBuilderAtEnd(g->builder, end_block);
20122033
20132034 add_debug_source_node(g, node);
2014 LLVMValueRef phi = LLVMBuildPhi(g->builder, get_expr_type(node)->type_ref, "");
2035 LLVMValueRef phi = LLVMBuildPhi(g->builder, LLVMTypeOf(incoming_values.at(0)), "");
20152036 LLVMAddIncoming(phi, incoming_values.items, incoming_blocks.items, incoming_values.length);
20162037
20172038 return phi;
std/std.zig+50-69
......@@ -5,7 +5,6 @@ pub const stdin_fileno = 0;
55pub const stdout_fileno = 1;
66pub const stderr_fileno = 2;
77
8/*
98pub var stdin = InStream {
109 .fd = stdin_fileno,
1110};
......@@ -23,9 +22,16 @@ pub var stderr = OutStream {
2322 .index = 0,
2423 .buffered = false,
2524};
26*/
2725
26/// The function received invalid input at runtime. An Invalid error means a
27/// bug in the program that called the function.
28pub error Invalid;
29
30/// When an Unexpected error occurs, code that emitted the error likely needs
31/// a patch to recognize the unexpected case so that it can handle it and emit
32/// a more specific error.
2833pub error Unexpected;
34
2935pub error DiskQuota;
3036pub error FileTooBig;
3137pub error SigInterrupt;
......@@ -33,26 +39,25 @@ pub error Io;
3339pub error NoSpaceLeft;
3440pub error BadPerm;
3541pub error PipeFail;
36pub error Invalid;
42pub error BadFd;
3743
3844const buffer_size = 4 * 1024;
3945const max_u64_base10_digits = 20;
4046
41/*
4247pub struct OutStream {
4348 fd: isize,
4449 buffer: [buffer_size]u8,
45 index: @typeof(buffer_size),
50 index: isize,
4651 buffered: bool,
4752
4853 pub fn print_str(os: &OutStream, str: []const u8) %isize => {
4954 var src_bytes_left = str.len;
5055 var src_index: @typeof(str.len) = 0;
51 const dest_space_left = os.buffer.len - index;
56 const dest_space_left = os.buffer.len - os.index;
5257
5358 while (src_bytes_left > 0) {
5459 const copy_amt = min_isize(dest_space_left, src_bytes_left);
55 @memcpy(&buffer[os.index], &str[src_index], copy_amt);
60 @memcpy(&os.buffer[os.index], &str[src_index], copy_amt);
5661 os.index += copy_amt;
5762 if (os.index == os.buffer.len) {
5863 %return os.flush();
......@@ -65,11 +70,19 @@ pub struct OutStream {
6570 return str.len;
6671 }
6772
73 /// Prints a byte buffer, flushes the buffer, then returns the number of
74 /// bytes printed. The "f" is for "flush".
75 pub fn printf(os: &OutStream, str: []const u8) %isize => {
76 const byte_count = %return os.print_str(str);
77 %return os.flush();
78 return byte_count;
79 }
80
6881 pub fn print_u64(os: &OutStream, x: u64) %isize => {
6982 if (os.index + max_u64_base10_digits >= os.buffer.len) {
7083 %return os.flush();
7184 }
72 const amt_printed = buf_print_u64(buf[os.index...], x);
85 const amt_printed = buf_print_u64(os.buffer[os.index...], x);
7386 os.index += amt_printed;
7487
7588 if (!os.buffered) {
......@@ -84,7 +97,7 @@ pub struct OutStream {
8497 if (os.index + max_u64_base10_digits >= os.buffer.len) {
8598 %return os.flush();
8699 }
87 const amt_printed = buf_print_i64(buf[os.index...], x);
100 const amt_printed = buf_print_i64(os.buffer[os.index...], x);
88101 os.index += amt_printed;
89102
90103 if (!os.buffered) {
......@@ -96,18 +109,20 @@ pub struct OutStream {
96109
97110
98111 pub fn flush(os: &OutStream) %void => {
99 const amt_to_write = os.index;
112 const amt_written = write(os.fd, os.buffer.ptr, os.index);
100113 os.index = 0;
101 switch (write(os.fd, os.buffer.ptr, amt_to_write)) {
102 EINVAL => unreachable{},
103 EDQUOT => error.DiskQuota,
104 EFBIG => error.FileTooBig,
105 EINTR => error.SigInterrupt,
106 EIO => error.Io,
107 ENOSPC => error.NoSpaceLeft,
108 EPERM => error.BadPerm,
109 EPIPE => error.PipeFail,
110 else => error.Unexpected,
114 if (amt_written < 0) {
115 return switch (-amt_written) {
116 EINVAL => unreachable{},
117 EDQUOT => error.DiskQuota,
118 EFBIG => error.FileTooBig,
119 EINTR => error.SigInterrupt,
120 EIO => error.Io,
121 ENOSPC => error.NoSpaceLeft,
122 EPERM => error.BadPerm,
123 EPIPE => error.PipeFail,
124 else => error.Unexpected,
125 }
111126 }
112127 }
113128}
......@@ -115,10 +130,10 @@ pub struct OutStream {
115130pub struct InStream {
116131 fd: isize,
117132
118 pub fn readline(buf: []u8) %isize => {
119 const amt_read = read(stdin_fileno, buf.ptr, buf.len);
133 pub fn readline(is: &InStream, buf: []u8) %isize => {
134 const amt_read = read(is.fd, buf.ptr, buf.len);
120135 if (amt_read < 0) {
121 switch (-amt_read) {
136 return switch (-amt_read) {
122137 EINVAL => unreachable{},
123138 EFAULT => unreachable{},
124139 EBADF => error.BadFd,
......@@ -133,53 +148,15 @@ pub struct InStream {
133148}
134149
135150pub fn os_get_random_bytes(buf: []u8) %void => {
136 switch (getrandom(buf.ptr, buf.len, 0)) {
137 EINVAL => unreachable{},
138 EFAULT => unreachable{},
139 EINTR => error.SigInterrupt,
140 else => error.Unexpected,
141 }
142}
143*/
144
145
146// TODO remove this
147pub fn print_str(str: []const u8) isize => {
148 fprint_str(stdout_fileno, str)
149}
150
151// TODO remove this
152pub fn fprint_str(fd: isize, str: []const u8) isize => {
153 write(fd, str.ptr, str.len)
154}
155
156// TODO remove this
157pub fn os_get_random_bytes(buf: []u8) isize => {
158 getrandom(buf.ptr, buf.len, 0)
159}
160
161// TODO remove this
162pub fn print_u64(x: u64) isize => {
163 var buf: [max_u64_base10_digits]u8;
164 const len = buf_print_u64(buf, x);
165 return write(stdout_fileno, buf.ptr, len);
166}
167
168// TODO remove this
169pub fn print_i64(x: i64) isize => {
170 var buf: [max_u64_base10_digits]u8;
171 const len = buf_print_i64(buf, x);
172 return write(stdout_fileno, buf.ptr, len);
173}
174
175// TODO remove this
176pub fn readline(buf: []u8, out_len: &isize) bool => {
177 const amt_read = read(stdin_fileno, buf.ptr, buf.len);
178 if (amt_read < 0) {
179 return true;
151 const amt_got = getrandom(buf.ptr, buf.len, 0);
152 if (amt_got < 0) {
153 return switch (-amt_got) {
154 EINVAL => unreachable{},
155 EFAULT => unreachable{},
156 EINTR => error.SigInterrupt,
157 else => error.Unexpected,
158 }
180159 }
181 *out_len = isize(amt_read);
182 return false;
183160}
184161
185162
......@@ -251,3 +228,7 @@ fn buf_print_u64(out_buf: []u8, x: u64) isize => {
251228
252229 return len;
253230}
231
232fn min_isize(x: isize, y: isize) isize => {
233 if (x < y) x else y
234}
std/syscall.zig+7-7
......@@ -1,7 +1,7 @@
1const SYS_read : isize = 0;
2const SYS_write : isize = 1;
3const SYS_exit : isize = 60;
4const SYS_getrandom : isize = 318;
1const SYS_read = 0;
2const SYS_write = 1;
3const SYS_exit = 60;
4const SYS_getrandom = 318;
55
66fn syscall1(number: isize, arg1: isize) isize => {
77 asm volatile ("syscall"
......@@ -18,11 +18,11 @@ fn syscall3(number: isize, arg1: isize, arg2: isize, arg3: isize) isize => {
1818}
1919
2020pub fn read(fd: isize, buf: &u8, count: isize) isize => {
21 isize(syscall3(SYS_read, isize(fd), isize(buf), count))
21 syscall3(SYS_read, isize(fd), isize(buf), count)
2222}
2323
2424pub fn write(fd: isize, buf: &const u8, count: isize) isize => {
25 isize(syscall3(SYS_write, isize(fd), isize(buf), count))
25 syscall3(SYS_write, isize(fd), isize(buf), count)
2626}
2727
2828pub fn exit(status: i32) unreachable => {
......@@ -31,5 +31,5 @@ pub fn exit(status: i32) unreachable => {
3131}
3232
3333pub fn getrandom(buf: &u8, count: isize, flags: u32) isize => {
34 isize(syscall3(SYS_getrandom, isize(buf), count, isize(flags)))
34 syscall3(SYS_getrandom, isize(buf), count, isize(flags))
3535}
test/run_tests.cpp+186-186
......@@ -121,7 +121,7 @@ pub fn main(args: [][]u8) %void => {
121121}
122122
123123fn this_is_a_function() unreachable => {
124 print_str("OK\n");
124 stdout.printf("OK\n");
125125 exit(0);
126126}
127127 )SOURCE", "OK\n");
......@@ -137,7 +137,7 @@ fn another_function() => {}
137137/// this is a documentation comment
138138/// doc comment line 2
139139pub fn main(args: [][]u8) %void => {
140 print_str(/* mid-line comment /* nested */ */ "OK\n");
140 stdout.printf(/* mid-line comment /* nested */ */ "OK\n");
141141}
142142 )SOURCE", "OK\n");
143143
......@@ -148,7 +148,7 @@ import "foo.zig";
148148
149149pub fn main(args: [][]u8) %void => {
150150 private_function();
151 print_str("OK 2\n");
151 stdout.printf("OK 2\n");
152152}
153153
154154fn private_function() => {
......@@ -162,7 +162,7 @@ import "std.zig";
162162// purposefully conflicting function with main.zig
163163// but it's private so it should be OK
164164fn private_function() => {
165 print_str("OK 1\n");
165 stdout.printf("OK 1\n");
166166}
167167
168168pub fn print_text() => {
......@@ -185,7 +185,7 @@ pub fn main(args: [][]u8) %void => {
185185 add_source_file(tc, "foo.zig", R"SOURCE(
186186import "std.zig";
187187pub fn foo_function() => {
188 print_str("OK\n");
188 stdout.printf("OK\n");
189189}
190190 )SOURCE");
191191
......@@ -195,7 +195,7 @@ import "std.zig";
195195
196196pub fn bar_function() => {
197197 if (foo_function()) {
198 print_str("OK\n");
198 stdout.printf("OK\n");
199199 }
200200}
201201 )SOURCE");
......@@ -213,17 +213,17 @@ import "std.zig";
213213
214214pub fn main(args: [][]u8) %void => {
215215 if (1 != 0) {
216 print_str("1 is true\n");
216 stdout.printf("1 is true\n");
217217 } else {
218 print_str("1 is false\n");
218 stdout.printf("1 is false\n");
219219 }
220220 if (0 != 0) {
221 print_str("0 is true\n");
221 stdout.printf("0 is true\n");
222222 } else if (1 - 1 != 0) {
223 print_str("1 - 1 is true\n");
223 stdout.printf("1 - 1 is true\n");
224224 }
225225 if (!(0 != 0)) {
226 print_str("!0 is true\n");
226 stdout.printf("!0 is true\n");
227227 }
228228}
229229 )SOURCE", "1 is true\n!0 is true\n");
......@@ -237,7 +237,7 @@ fn add(a: i32, b: i32) i32 => {
237237
238238pub fn main(args: [][]u8) %void => {
239239 if (add(22, 11) == 33) {
240 print_str("pass\n");
240 stdout.printf("pass\n");
241241 }
242242}
243243 )SOURCE", "pass\n");
......@@ -249,7 +249,7 @@ fn loop(a : i32) => {
249249 if (a == 0) {
250250 goto done;
251251 }
252 print_str("loop\n");
252 stdout.printf("loop\n");
253253 loop(a - 1);
254254
255255done:
......@@ -268,7 +268,7 @@ pub fn main(args: [][]u8) %void => {
268268 const a : i32 = 1;
269269 const b = i32(2);
270270 if (a + b == 3) {
271 print_str("OK\n");
271 stdout.printf("OK\n");
272272 }
273273}
274274 )SOURCE", "OK\n");
......@@ -277,10 +277,10 @@ pub fn main(args: [][]u8) %void => {
277277import "std.zig";
278278
279279pub fn main(args: [][]u8) %void => {
280 if (true) { print_str("OK 1\n"); }
281 if (false) { print_str("BAD 1\n"); }
282 if (!true) { print_str("BAD 2\n"); }
283 if (!false) { print_str("OK 2\n"); }
280 if (true) { stdout.printf("OK 1\n"); }
281 if (false) { stdout.printf("BAD 1\n"); }
282 if (!true) { stdout.printf("BAD 2\n"); }
283 if (!false) { stdout.printf("OK 2\n"); }
284284}
285285 )SOURCE", "OK 1\nOK 2\n");
286286
......@@ -290,14 +290,14 @@ import "std.zig";
290290pub fn main(args: [][]u8) %void => {
291291 if (true) {
292292 const no_conflict : i32 = 5;
293 if (no_conflict == 5) { print_str("OK 1\n"); }
293 if (no_conflict == 5) { stdout.printf("OK 1\n"); }
294294 }
295295
296296 const c = {
297297 const no_conflict = i32(10);
298298 no_conflict
299299 };
300 if (c == 10) { print_str("OK 2\n"); }
300 if (c == 10) { stdout.printf("OK 2\n"); }
301301}
302302 )SOURCE", "OK 1\nOK 2\n");
303303
......@@ -311,7 +311,7 @@ pub fn main(args: [][]u8) %void => {
311311fn void_fun(a : i32, b : void, c : i32) => {
312312 const v = b;
313313 const vv : void = if (a == 1) {v} else {};
314 if (a + c == 3) { print_str("OK\n"); }
314 if (a + c == 3) { stdout.printf("OK\n"); }
315315 return vv;
316316}
317317 )SOURCE", "OK\n");
......@@ -330,12 +330,12 @@ pub fn main(args: [][]u8) %void => {
330330 .c = void{},
331331 };
332332 if (foo.b != 1) {
333 print_str("BAD\n");
333 stdout.printf("BAD\n");
334334 }
335335 if (@sizeof(Foo) != 4) {
336 print_str("BAD\n");
336 stdout.printf("BAD\n");
337337 }
338 print_str("OK\n");
338 stdout.printf("OK\n");
339339}
340340
341341 )SOURCE", "OK\n");
......@@ -348,12 +348,12 @@ pub fn main(args: [][]u8) %void => {
348348 array[0] = void{};
349349 array[1] = array[2];
350350 if (@sizeof(@typeof(array)) != 0) {
351 print_str("BAD\n");
351 stdout.printf("BAD\n");
352352 }
353353 if (array.len != 4) {
354 print_str("BAD\n");
354 stdout.printf("BAD\n");
355355 }
356 print_str("OK\n");
356 stdout.printf("OK\n");
357357}
358358 )SOURCE", "OK\n");
359359
......@@ -363,11 +363,11 @@ import "std.zig";
363363
364364pub fn main(args: [][]u8) %void => {
365365 var zero : i32 = 0;
366 if (zero == 0) { print_str("zero\n"); }
366 if (zero == 0) { stdout.printf("zero\n"); }
367367
368368 var i = i32(0);
369369 while (i != 3) {
370 print_str("loop\n");
370 stdout.printf("loop\n");
371371 i += 1;
372372 }
373373}
......@@ -394,11 +394,11 @@ pub fn main(args: [][]u8) %void => {
394394 }
395395
396396 if (accumulator == 15) {
397 print_str("OK\n");
397 stdout.printf("OK\n");
398398 }
399399
400400 if (get_array_len(array) != 5) {
401 print_str("BAD\n");
401 stdout.printf("BAD\n");
402402 }
403403}
404404fn get_array_len(a: []i32) isize => {
......@@ -411,7 +411,7 @@ fn get_array_len(a: []i32) isize => {
411411import "std.zig";
412412
413413pub fn main(args: [][]u8) %void => {
414 print_str("Hello, world!\n");
414 stdout.printf("Hello, world!\n");
415415}
416416 )SOURCE", "Hello, world!\n");
417417
......@@ -420,20 +420,20 @@ pub fn main(args: [][]u8) %void => {
420420import "std.zig";
421421
422422pub fn main(args: [][]u8) %void => {
423 if (false || false || false) { print_str("BAD 1\n"); }
424 if (true && true && false) { print_str("BAD 2\n"); }
425 if (1 | 2 | 4 != 7) { print_str("BAD 3\n"); }
426 if (3 ^ 6 ^ 8 != 13) { print_str("BAD 4\n"); }
427 if (7 & 14 & 28 != 4) { print_str("BAD 5\n"); }
428 if (9 << 1 << 2 != 9 << 3) { print_str("BAD 6\n"); }
429 if (90 >> 1 >> 2 != 90 >> 3) { print_str("BAD 7\n"); }
430 if (100 - 1 + 1000 != 1099) { print_str("BAD 8\n"); }
431 if (5 * 4 / 2 % 3 != 1) { print_str("BAD 9\n"); }
432 if (i32(i32(5)) != 5) { print_str("BAD 10\n"); }
433 if (!!false) { print_str("BAD 11\n"); }
434 if (i32(7) != --(i32(7))) { print_str("BAD 12\n"); }
435
436 print_str("OK\n");
423 if (false || false || false) { stdout.printf("BAD 1\n"); }
424 if (true && true && false) { stdout.printf("BAD 2\n"); }
425 if (1 | 2 | 4 != 7) { stdout.printf("BAD 3\n"); }
426 if (3 ^ 6 ^ 8 != 13) { stdout.printf("BAD 4\n"); }
427 if (7 & 14 & 28 != 4) { stdout.printf("BAD 5\n"); }
428 if (9 << 1 << 2 != 9 << 3) { stdout.printf("BAD 6\n"); }
429 if (90 >> 1 >> 2 != 90 >> 3) { stdout.printf("BAD 7\n"); }
430 if (100 - 1 + 1000 != 1099) { stdout.printf("BAD 8\n"); }
431 if (5 * 4 / 2 % 3 != 1) { stdout.printf("BAD 9\n"); }
432 if (i32(i32(5)) != 5) { stdout.printf("BAD 10\n"); }
433 if (!!false) { stdout.printf("BAD 11\n"); }
434 if (i32(7) != --(i32(7))) { stdout.printf("BAD 12\n"); }
435
436 stdout.printf("OK\n");
437437}
438438 )SOURCE", "OK\n");
439439
......@@ -441,19 +441,19 @@ pub fn main(args: [][]u8) %void => {
441441import "std.zig";
442442
443443pub fn main(args: [][]u8) %void => {
444 if (true || { print_str("BAD 1\n"); false }) {
445 print_str("OK 1\n");
444 if (true || { stdout.printf("BAD 1\n"); false }) {
445 stdout.printf("OK 1\n");
446446 }
447 if (false || { print_str("OK 2\n"); false }) {
448 print_str("BAD 2\n");
447 if (false || { stdout.printf("OK 2\n"); false }) {
448 stdout.printf("BAD 2\n");
449449 }
450450
451 if (true && { print_str("OK 3\n"); false }) {
452 print_str("BAD 3\n");
451 if (true && { stdout.printf("OK 3\n"); false }) {
452 stdout.printf("BAD 3\n");
453453 }
454 if (false && { print_str("BAD 4\n"); false }) {
454 if (false && { stdout.printf("BAD 4\n"); false }) {
455455 } else {
456 print_str("OK 4\n");
456 stdout.printf("OK 4\n");
457457 }
458458}
459459 )SOURCE", "OK 1\nOK 2\nOK 3\nOK 4\n");
......@@ -463,20 +463,20 @@ import "std.zig";
463463
464464pub fn main(args: [][]u8) %void => {
465465 var i : i32 = 0;
466 i += 5; if (i != 5) { print_str("BAD +=\n"); }
467 i -= 2; if (i != 3) { print_str("BAD -=\n"); }
468 i *= 20; if (i != 60) { print_str("BAD *=\n"); }
469 i /= 3; if (i != 20) { print_str("BAD /=\n"); }
470 i %= 11; if (i != 9) { print_str("BAD %=\n"); }
471 i <<= 1; if (i != 18) { print_str("BAD <<=\n"); }
472 i >>= 2; if (i != 4) { print_str("BAD >>=\n"); }
466 i += 5; if (i != 5) { stdout.printf("BAD +=\n"); }
467 i -= 2; if (i != 3) { stdout.printf("BAD -=\n"); }
468 i *= 20; if (i != 60) { stdout.printf("BAD *=\n"); }
469 i /= 3; if (i != 20) { stdout.printf("BAD /=\n"); }
470 i %= 11; if (i != 9) { stdout.printf("BAD %=\n"); }
471 i <<= 1; if (i != 18) { stdout.printf("BAD <<=\n"); }
472 i >>= 2; if (i != 4) { stdout.printf("BAD >>=\n"); }
473473 i = 6;
474 i &= 5; if (i != 4) { print_str("BAD &=\n"); }
475 i ^= 6; if (i != 2) { print_str("BAD ^=\n"); }
474 i &= 5; if (i != 4) { stdout.printf("BAD &=\n"); }
475 i ^= 6; if (i != 2) { stdout.printf("BAD ^=\n"); }
476476 i = 6;
477 i |= 3; if (i != 7) { print_str("BAD |=\n"); }
477 i |= 3; if (i != 7) { stdout.printf("BAD |=\n"); }
478478
479 print_str("OK\n");
479 stdout.printf("OK\n");
480480}
481481 )SOURCE", "OK\n");
482482
......@@ -620,12 +620,12 @@ pub fn main(args: [][]u8) %void => {
620620 test_foo(foo);
621621 test_mutation(&foo);
622622 if (foo.c != 100) {
623 print_str("BAD\n");
623 stdout.printf("BAD\n");
624624 }
625625 test_point_to_self();
626626 test_byval_assign();
627627 test_initializer();
628 print_str("OK\n");
628 stdout.printf("OK\n");
629629}
630630struct Foo {
631631 a : i32,
......@@ -634,7 +634,7 @@ struct Foo {
634634}
635635fn test_foo(foo : Foo) => {
636636 if (!foo.b) {
637 print_str("BAD\n");
637 stdout.printf("BAD\n");
638638 }
639639}
640640fn test_mutation(foo : &Foo) => {
......@@ -659,7 +659,7 @@ fn test_point_to_self() => {
659659 root.next = &node;
660660
661661 if (node.next.next.next.val.x != 1) {
662 print_str("BAD\n");
662 stdout.printf("BAD\n");
663663 }
664664}
665665fn test_byval_assign() => {
......@@ -668,15 +668,15 @@ fn test_byval_assign() => {
668668
669669 foo1.a = 1234;
670670
671 if (foo2.a != 0) { print_str("BAD\n"); }
671 if (foo2.a != 0) { stdout.printf("BAD\n"); }
672672
673673 foo2 = foo1;
674674
675 if (foo2.a != 1234) { print_str("BAD - byval assignment failed\n"); }
675 if (foo2.a != 1234) { stdout.printf("BAD - byval assignment failed\n"); }
676676}
677677fn test_initializer() => {
678678 const val = Val { .x = 42 };
679 if (val.x != 42) { print_str("BAD\n"); }
679 if (val.x != 42) { stdout.printf("BAD\n"); }
680680}
681681 )SOURCE", "OK\n");
682682
......@@ -687,10 +687,10 @@ const g1 : i32 = 1233 + 1;
687687var g2 : i32 = 0;
688688
689689pub fn main(args: [][]u8) %void => {
690 if (g2 != 0) { print_str("BAD\n"); }
690 if (g2 != 0) { stdout.printf("BAD\n"); }
691691 g2 = g1;
692 if (g2 != 1234) { print_str("BAD\n"); }
693 print_str("OK\n");
692 if (g2 != 1234) { stdout.printf("BAD\n"); }
693 stdout.printf("OK\n");
694694}
695695 )SOURCE", "OK\n");
696696
......@@ -699,7 +699,7 @@ import "std.zig";
699699pub fn main(args: [][]u8) %void => {
700700 var i : i32 = 0;
701701 while (i < 4) {
702 print_str("loop\n");
702 stdout.printf("loop\n");
703703 i += 1;
704704 }
705705 g();
......@@ -719,7 +719,7 @@ import "std.zig";
719719pub fn main(args: [][]u8) %void => {
720720 var i : i32 = 0;
721721 while (true) {
722 print_str("loop\n");
722 stdout.printf("loop\n");
723723 i += 1;
724724 if (i < 4) {
725725 continue;
......@@ -736,12 +736,12 @@ pub fn main(args: [][]u8) %void => {
736736
737737 if (const y ?= x) {
738738 if (y) {
739 print_str("x is true\n");
739 stdout.printf("x is true\n");
740740 } else {
741 print_str("x is false\n");
741 stdout.printf("x is false\n");
742742 }
743743 } else {
744 print_str("x is none\n");
744 stdout.printf("x is none\n");
745745 }
746746
747747 const next_x : ?i32 = null;
......@@ -749,7 +749,7 @@ pub fn main(args: [][]u8) %void => {
749749 const z = next_x ?? 1234;
750750
751751 if (z != 1234) {
752 print_str("BAD\n");
752 stdout.printf("BAD\n");
753753 }
754754
755755 const final_x : ?i32 = 13;
......@@ -757,7 +757,7 @@ pub fn main(args: [][]u8) %void => {
757757 const num = final_x ?? unreachable{};
758758
759759 if (num != 13) {
760 print_str("BAD\n");
760 stdout.printf("BAD\n");
761761 }
762762}
763763 )SOURCE", "x is true\n");
......@@ -767,7 +767,7 @@ import "std.zig";
767767pub fn main(args: [][]u8) %void => {
768768 const x = outer();
769769 if (x == 1234) {
770 print_str("OK\n");
770 stdout.printf("OK\n");
771771 }
772772}
773773fn inner() i32 => { 1234 }
......@@ -782,8 +782,8 @@ const x: u16 = 13;
782782const z: @typeof(x) = 19;
783783pub fn main(args: [][]u8) %void => {
784784 const y: @typeof(x) = 120;
785 print_u64(@sizeof(@typeof(y)));
786 print_str("\n");
785 stdout.print_u64(@sizeof(@typeof(y)));
786 stdout.printf("\n");
787787}
788788 )SOURCE", "2\n");
789789
......@@ -798,9 +798,9 @@ struct Rand {
798798pub fn main(args: [][]u8) %void => {
799799 const r = Rand {.seed = 1234};
800800 if (r.get_seed() != 1234) {
801 print_str("BAD seed\n");
801 stdout.printf("BAD seed\n");
802802 }
803 print_str("OK\n");
803 stdout.printf("OK\n");
804804}
805805 )SOURCE", "OK\n");
806806
......@@ -814,12 +814,12 @@ pub fn main(args: [][]u8) %void => {
814814 *y += 1;
815815
816816 if (x != 4) {
817 print_str("BAD\n");
817 stdout.printf("BAD\n");
818818 }
819819 if (*y != 4) {
820 print_str("BAD\n");
820 stdout.printf("BAD\n");
821821 }
822 print_str("OK\n");
822 stdout.printf("OK\n");
823823}
824824 )SOURCE", "OK\n");
825825
......@@ -830,77 +830,77 @@ const ARRAY_SIZE : i8 = 20;
830830
831831pub fn main(args: [][]u8) %void => {
832832 var array : [ARRAY_SIZE]u8;
833 print_u64(@sizeof(@typeof(array)));
834 print_str("\n");
833 stdout.print_u64(@sizeof(@typeof(array)));
834 stdout.printf("\n");
835835}
836836 )SOURCE", "20\n");
837837
838838 add_simple_case("@min_value() and @max_value()", R"SOURCE(
839839import "std.zig";
840840pub fn main(args: [][]u8) %void => {
841 print_str("max u8: ");
842 print_u64(@max_value(u8));
843 print_str("\n");
841 stdout.printf("max u8: ");
842 stdout.print_u64(@max_value(u8));
843 stdout.printf("\n");
844844
845 print_str("max u16: ");
846 print_u64(@max_value(u16));
847 print_str("\n");
845 stdout.printf("max u16: ");
846 stdout.print_u64(@max_value(u16));
847 stdout.printf("\n");
848848
849 print_str("max u32: ");
850 print_u64(@max_value(u32));
851 print_str("\n");
849 stdout.printf("max u32: ");
850 stdout.print_u64(@max_value(u32));
851 stdout.printf("\n");
852852
853 print_str("max u64: ");
854 print_u64(@max_value(u64));
855 print_str("\n");
853 stdout.printf("max u64: ");
854 stdout.print_u64(@max_value(u64));
855 stdout.printf("\n");
856856
857 print_str("max i8: ");
858 print_i64(@max_value(i8));
859 print_str("\n");
857 stdout.printf("max i8: ");
858 stdout.print_i64(@max_value(i8));
859 stdout.printf("\n");
860860
861 print_str("max i16: ");
862 print_i64(@max_value(i16));
863 print_str("\n");
861 stdout.printf("max i16: ");
862 stdout.print_i64(@max_value(i16));
863 stdout.printf("\n");
864864
865 print_str("max i32: ");
866 print_i64(@max_value(i32));
867 print_str("\n");
865 stdout.printf("max i32: ");
866 stdout.print_i64(@max_value(i32));
867 stdout.printf("\n");
868868
869 print_str("max i64: ");
870 print_i64(@max_value(i64));
871 print_str("\n");
869 stdout.printf("max i64: ");
870 stdout.print_i64(@max_value(i64));
871 stdout.printf("\n");
872872
873 print_str("min u8: ");
874 print_u64(@min_value(u8));
875 print_str("\n");
873 stdout.printf("min u8: ");
874 stdout.print_u64(@min_value(u8));
875 stdout.printf("\n");
876876
877 print_str("min u16: ");
878 print_u64(@min_value(u16));
879 print_str("\n");
877 stdout.printf("min u16: ");
878 stdout.print_u64(@min_value(u16));
879 stdout.printf("\n");
880880
881 print_str("min u32: ");
882 print_u64(@min_value(u32));
883 print_str("\n");
881 stdout.printf("min u32: ");
882 stdout.print_u64(@min_value(u32));
883 stdout.printf("\n");
884884
885 print_str("min u64: ");
886 print_u64(@min_value(u64));
887 print_str("\n");
885 stdout.printf("min u64: ");
886 stdout.print_u64(@min_value(u64));
887 stdout.printf("\n");
888888
889 print_str("min i8: ");
890 print_i64(@min_value(i8));
891 print_str("\n");
889 stdout.printf("min i8: ");
890 stdout.print_i64(@min_value(i8));
891 stdout.printf("\n");
892892
893 print_str("min i16: ");
894 print_i64(@min_value(i16));
895 print_str("\n");
893 stdout.printf("min i16: ");
894 stdout.print_i64(@min_value(i16));
895 stdout.printf("\n");
896896
897 print_str("min i32: ");
898 print_i64(@min_value(i32));
899 print_str("\n");
897 stdout.printf("min i32: ");
898 stdout.print_i64(@min_value(i32));
899 stdout.printf("\n");
900900
901 print_str("min i64: ");
902 print_i64(@min_value(i64));
903 print_str("\n");
901 stdout.printf("min i64: ");
902 stdout.print_i64(@min_value(i64));
903 stdout.printf("\n");
904904}
905905 )SOURCE",
906906 "max u8: 255\n"
......@@ -931,19 +931,19 @@ pub fn main(args: [][]u8) %void => {
931931 var slice = array[5...10];
932932
933933 if (slice.len != 5) {
934 print_str("BAD\n");
934 stdout.printf("BAD\n");
935935 }
936936
937937 if (slice.ptr[0] != 1234) {
938 print_str("BAD\n");
938 stdout.printf("BAD\n");
939939 }
940940
941941 var slice_rest = array[10...];
942942 if (slice_rest.len != 10) {
943 print_str("BAD\n");
943 stdout.printf("BAD\n");
944944 }
945945
946 print_str("OK\n");
946 stdout.printf("OK\n");
947947}
948948 )SOURCE", "OK\n");
949949
......@@ -952,7 +952,7 @@ pub fn main(args: [][]u8) %void => {
952952import "std.zig";
953953pub fn main(args: [][]u8) %void => {
954954 if (f(1) == 1) {
955 print_str("OK\n");
955 stdout.printf("OK\n");
956956 }
957957}
958958fn f(c: u8) u8 => {
......@@ -971,15 +971,15 @@ import "std.zig";
971971pub fn main(args: [][]u8) %void => {
972972 var result: u8;
973973 if (!@add_with_overflow(u8, 250, 100, &result)) {
974 print_str("BAD\n");
974 stdout.printf("BAD\n");
975975 }
976976 if (@add_with_overflow(u8, 100, 150, &result)) {
977 print_str("BAD\n");
977 stdout.printf("BAD\n");
978978 }
979979 if (result != 250) {
980 print_str("BAD\n");
980 stdout.printf("BAD\n");
981981 }
982 print_str("OK\n");
982 stdout.printf("OK\n");
983983}
984984 )SOURCE", "OK\n");
985985
......@@ -993,10 +993,10 @@ pub fn main(args: [][]u8) %void => {
993993 @memcpy(bar.ptr, foo.ptr, bar.len);
994994
995995 if (bar[11] != 'A') {
996 print_str("BAD\n");
996 stdout.printf("BAD\n");
997997 }
998998
999 print_str("OK\n");
999 stdout.printf("OK\n");
10001000}
10011001 )SOURCE", "OK\n");
10021002
......@@ -1009,7 +1009,7 @@ pub fn main(args: [][]u8) %void => {
10091009 var x : i32 = print_ok(x);
10101010}
10111011fn print_ok(val: @typeof(x)) @typeof(foo) => {
1012 print_str("OK\n");
1012 stdout.printf("OK\n");
10131013 return 0;
10141014}
10151015const foo : i32 = 0;
......@@ -1042,25 +1042,25 @@ pub fn main(args: [][]u8) %void => {
10421042 const bar = Bar.B;
10431043
10441044 if (bar != Bar.B) {
1045 print_str("BAD\n");
1045 stdout.printf("BAD\n");
10461046 }
10471047
10481048 if (@member_count(Foo) != 3) {
1049 print_str("BAD\n");
1049 stdout.printf("BAD\n");
10501050 }
10511051
10521052 if (@member_count(Bar) != 4) {
1053 print_str("BAD\n");
1053 stdout.printf("BAD\n");
10541054 }
10551055
10561056 if (@sizeof(Foo) != 17) {
1057 print_str("BAD\n");
1057 stdout.printf("BAD\n");
10581058 }
10591059 if (@sizeof(Bar) != 1) {
1060 print_str("BAD\n");
1060 stdout.printf("BAD\n");
10611061 }
10621062
1063 print_str("OK\n");
1063 stdout.printf("OK\n");
10641064}
10651065 )SOURCE", "OK\n");
10661066
......@@ -1071,14 +1071,14 @@ pub fn main(args: [][]u8) %void => {
10711071 const HEX_MULT = []u16{4096, 256, 16, 1};
10721072
10731073 if (HEX_MULT.len != 4) {
1074 print_str("BAD\n");
1074 stdout.printf("BAD\n");
10751075 }
10761076
10771077 if (HEX_MULT[1] != 256) {
1078 print_str("BAD\n");
1078 stdout.printf("BAD\n");
10791079 }
10801080
1081 print_str("OK\n");
1081 stdout.printf("OK\n");
10821082}
10831083 )SOURCE", "OK\n");
10841084
......@@ -1089,8 +1089,8 @@ pub fn main(args: [][]u8) %void => {
10891089 const array_of_strings = [][]u8 {"hello", "this", "is", "my", "thing"};
10901090 var i: @typeof(array_of_strings.len) = 0;
10911091 while (i < array_of_strings.len) {
1092 print_str(array_of_strings[i]);
1093 print_str("\n");
1092 stdout.printf(array_of_strings[i]);
1093 stdout.printf("\n");
10941094 i += 1;
10951095 }
10961096}
......@@ -1102,21 +1102,21 @@ import "std.zig";
11021102pub fn main(args: [][]u8) %void => {
11031103 const array = []u8 {9, 8, 7, 6};
11041104 for (item, array) {
1105 print_u64(item);
1106 print_str("\n");
1105 stdout.print_u64(item);
1106 stdout.printf("\n");
11071107 }
11081108 for (item, array, index) {
1109 print_i64(index);
1110 print_str("\n");
1109 stdout.print_i64(index);
1110 stdout.printf("\n");
11111111 }
11121112 const unknown_size: []u8 = array;
11131113 for (item, unknown_size) {
1114 print_u64(item);
1115 print_str("\n");
1114 stdout.print_u64(item);
1115 stdout.printf("\n");
11161116 }
11171117 for (item, unknown_size, index) {
1118 print_i64(index);
1119 print_str("\n");
1118 stdout.print_i64(index);
1119 stdout.printf("\n");
11201120 }
11211121}
11221122 )SOURCE", "9\n8\n7\n6\n0\n1\n2\n3\n9\n8\n7\n6\n0\n1\n2\n3\n");
......@@ -1127,8 +1127,8 @@ import "std.zig";
11271127pub fn main(args: [][]u8) %void => {
11281128 const fns = []@typeof(fn1) { fn1, fn2, fn3, fn4, };
11291129 for (f, fns) {
1130 print_u64(f());
1131 print_str("\n");
1130 stdout.print_u64(f());
1131 stdout.printf("\n");
11321132 }
11331133}
11341134
......@@ -1157,10 +1157,10 @@ pub fn main(args: [][]u8) %void => {
11571157 Foo.D => 4,
11581158 };
11591159 if (val != 3) {
1160 print_str("BAD\n");
1160 stdout.printf("BAD\n");
11611161 }
11621162
1163 print_str("OK\n");
1163 stdout.printf("OK\n");
11641164}
11651165 )SOURCE", "OK\n");
11661166
......@@ -1174,10 +1174,10 @@ pub fn main(args: [][]u8) %void => {
11741174 const eleven = ten + one;
11751175
11761176 if (eleven != 11) {
1177 print_str("BAD\n");
1177 stdout.printf("BAD\n");
11781178 }
11791179
1180 print_str("OK\n");
1180 stdout.printf("OK\n");
11811181}
11821182 )SOURCE", "OK\n");
11831183
......@@ -1191,10 +1191,10 @@ var foo = Foo { .x = 13, .y = true, };
11911191pub fn main(args: [][]u8) %void => {
11921192 foo.x += 1;
11931193 if (foo.x != 14) {
1194 print_str("BAD\n");
1194 stdout.printf("BAD\n");
11951195 }
11961196
1197 print_str("OK\n");
1197 stdout.printf("OK\n");
11981198}
11991199 )SOURCE", "OK\n");
12001200
......@@ -1204,10 +1204,10 @@ const x = []u8{1,2,3,4};
12041204pub fn main(args: [][]u8) %void => {
12051205 const y : [4]u8 = x;
12061206 if (y[3] != 4) {
1207 print_str("BAD\n");
1207 stdout.printf("BAD\n");
12081208 }
12091209
1210 print_str("OK\n");
1210 stdout.printf("OK\n");
12111211}
12121212 )SOURCE", "OK\n");
12131213
......@@ -1219,10 +1219,10 @@ pub fn main(args: [][]u8) %void => {
12191219 const a = i32(error.err1);
12201220 const b = i32(error.err2);
12211221 if (a == b) {
1222 print_str("BAD\n");
1222 stdout.printf("BAD\n");
12231223 }
12241224
1225 print_str("OK\n");
1225 stdout.printf("OK\n");
12261226}
12271227 )SOURCE", "OK\n");
12281228
......@@ -1230,7 +1230,7 @@ pub fn main(args: [][]u8) %void => {
12301230import "std.zig";
12311231pub fn main(args: [][]u8) %void => {
12321232 while (true) {
1233 print_str("OK\n");
1233 stdout.printf("OK\n");
12341234 return;
12351235 }
12361236}
......@@ -1251,9 +1251,9 @@ fn make_foo(x: i32, y: i32) Foo => {
12511251pub fn main(args: [][]u8) %void => {
12521252 const foo = make_foo(1234, 5678);
12531253 if (foo.y != 5678) {
1254 print_str("BAD\n");
1254 stdout.printf("BAD\n");
12551255 }
1256 print_str("OK\n");
1256 stdout.printf("OK\n");
12571257}
12581258 )SOURCE", "OK\n");
12591259}