| author | |
| committer | |
| log | 13c584d325d042879c8c56a3c41ffbf99a3346c0 |
| tree | 8dbe57f0ef8a1da2b9c6db9471a82ebe36aa90aa |
| parent | cba3b8291a18ee16cda2b453bb2bcd4279fa8b98 |
| signature |
See #30638 files changed, 39 insertions(+), 20 deletions(-)
src/ir.cpp+1| ... | ... | @@ -12112,6 +12112,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 12112 | 12112 | |
| 12113 | 12113 | // *@Frame(func) to anyframe->T or anyframe |
| 12114 | 12114 | if (actual_type->id == ZigTypeIdPointer && actual_type->data.pointer.ptr_len == PtrLenSingle && |
| 12115 | !actual_type->data.pointer.is_const && | |
| 12115 | 12116 | actual_type->data.pointer.child_type->id == ZigTypeIdFnFrame && wanted_type->id == ZigTypeIdAnyFrame) |
| 12116 | 12117 | { |
| 12117 | 12118 | bool ok = true; |
std/event/channel.zig+1-1| ... | ... | @@ -331,7 +331,7 @@ async fn testChannelGetter(loop: *Loop, channel: *Channel(i32)) void { |
| 331 | 331 | const value3 = channel.getOrNull(); |
| 332 | 332 | testing.expect(value3 == null); |
| 333 | 333 | |
| 334 | const last_put = async testPut(channel, 4444); | |
| 334 | var last_put = async testPut(channel, 4444); | |
| 335 | 335 | const value4 = channel.getOrNull(); |
| 336 | 336 | testing.expect(value4.? == 4444); |
| 337 | 337 | await last_put; |
std/event/future.zig+3-3| ... | ... | @@ -100,9 +100,9 @@ test "std.event.Future" { |
| 100 | 100 | async fn testFuture(loop: *Loop) void { |
| 101 | 101 | var future = Future(i32).init(loop); |
| 102 | 102 | |
| 103 | const a = async waitOnFuture(&future); | |
| 104 | const b = async waitOnFuture(&future); | |
| 105 | const c = async resolveFuture(&future); | |
| 103 | var a = async waitOnFuture(&future); | |
| 104 | var b = async waitOnFuture(&future); | |
| 105 | var c = async resolveFuture(&future); | |
| 106 | 106 | |
| 107 | 107 | // TODO make this work: |
| 108 | 108 | //const result = (await a) + (await b); |
std/event/lock.zig+5-5| ... | ... | @@ -135,7 +135,7 @@ test "std.event.Lock" { |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | async fn testLock(loop: *Loop, lock: *Lock) void { |
| 138 | const handle1 = async lockRunner(lock); | |
| 138 | var handle1 = async lockRunner(lock); | |
| 139 | 139 | var tick_node1 = Loop.NextTickNode{ |
| 140 | 140 | .prev = undefined, |
| 141 | 141 | .next = undefined, |
| ... | ... | @@ -143,7 +143,7 @@ async fn testLock(loop: *Loop, lock: *Lock) void { |
| 143 | 143 | }; |
| 144 | 144 | loop.onNextTick(&tick_node1); |
| 145 | 145 | |
| 146 | const handle2 = async lockRunner(lock); | |
| 146 | var handle2 = async lockRunner(lock); | |
| 147 | 147 | var tick_node2 = Loop.NextTickNode{ |
| 148 | 148 | .prev = undefined, |
| 149 | 149 | .next = undefined, |
| ... | ... | @@ -151,7 +151,7 @@ async fn testLock(loop: *Loop, lock: *Lock) void { |
| 151 | 151 | }; |
| 152 | 152 | loop.onNextTick(&tick_node2); |
| 153 | 153 | |
| 154 | const handle3 = async lockRunner(lock); | |
| 154 | var handle3 = async lockRunner(lock); | |
| 155 | 155 | var tick_node3 = Loop.NextTickNode{ |
| 156 | 156 | .prev = undefined, |
| 157 | 157 | .next = undefined, |
| ... | ... | @@ -172,8 +172,8 @@ async fn lockRunner(lock: *Lock) void { |
| 172 | 172 | |
| 173 | 173 | var i: usize = 0; |
| 174 | 174 | while (i < shared_test_data.len) : (i += 1) { |
| 175 | const lock_promise = async lock.acquire(); | |
| 176 | const handle = await lock_promise; | |
| 175 | var lock_frame = async lock.acquire(); | |
| 176 | const handle = await lock_frame; | |
| 177 | 177 | defer handle.release(); |
| 178 | 178 | |
| 179 | 179 | shared_test_index = 0; |
std/event/loop.zig+2-2| ... | ... | @@ -900,8 +900,8 @@ test "std.event.Loop - call" { |
| 900 | 900 | defer loop.deinit(); |
| 901 | 901 | |
| 902 | 902 | var did_it = false; |
| 903 | const handle = async Loop.call(testEventLoop); | |
| 904 | const handle2 = async Loop.call(testEventLoop2, &handle, &did_it); | |
| 903 | var handle = async Loop.call(testEventLoop); | |
| 904 | var handle2 = async Loop.call(testEventLoop2, &handle, &did_it); | |
| 905 | 905 | |
| 906 | 906 | loop.run(); |
| 907 | 907 |
test/compile_errors.zig+18| ... | ... | @@ -2,6 +2,24 @@ const tests = @import("tests.zig"); |
| 2 | 2 | const builtin = @import("builtin"); |
| 3 | 3 | |
| 4 | 4 | pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 5 | cases.add( | |
| 6 | "const frame cast to anyframe", | |
| 7 | \\export fn a() void { | |
| 8 | \\ const f = async func(); | |
| 9 | \\ resume f; | |
| 10 | \\} | |
| 11 | \\export fn b() void { | |
| 12 | \\ const f = async func(); | |
| 13 | \\ var x: anyframe = &f; | |
| 14 | \\} | |
| 15 | \\fn func() void { | |
| 16 | \\ suspend; | |
| 17 | \\} | |
| 18 | , | |
| 19 | "tmp.zig:3:12: error: expected type 'anyframe', found '*const @Frame(func)'", | |
| 20 | "tmp.zig:7:24: error: expected type 'anyframe', found '*const @Frame(func)'", | |
| 21 | ); | |
| 22 | ||
| 5 | 23 | cases.add( |
| 6 | 24 | "prevent bad implicit casting of anyframe types", |
| 7 | 25 | \\export fn a() void { |
test/stage1/behavior/async_fn.zig+7-7| ... | ... | @@ -6,7 +6,7 @@ const expectEqual = std.testing.expectEqual; |
| 6 | 6 | var global_x: i32 = 1; |
| 7 | 7 | |
| 8 | 8 | test "simple coroutine suspend and resume" { |
| 9 | const frame = async simpleAsyncFn(); | |
| 9 | var frame = async simpleAsyncFn(); | |
| 10 | 10 | expect(global_x == 2); |
| 11 | 11 | resume frame; |
| 12 | 12 | expect(global_x == 3); |
| ... | ... | @@ -25,7 +25,7 @@ fn simpleAsyncFn() void { |
| 25 | 25 | var global_y: i32 = 1; |
| 26 | 26 | |
| 27 | 27 | test "pass parameter to coroutine" { |
| 28 | const p = async simpleAsyncFnWithArg(2); | |
| 28 | var p = async simpleAsyncFnWithArg(2); | |
| 29 | 29 | expect(global_y == 3); |
| 30 | 30 | resume p; |
| 31 | 31 | expect(global_y == 5); |
| ... | ... | @@ -60,7 +60,7 @@ test "local variable in async function" { |
| 60 | 60 | |
| 61 | 61 | fn doTheTest() void { |
| 62 | 62 | expect(x == 0); |
| 63 | const p = async add(1, 2); | |
| 63 | var p = async add(1, 2); | |
| 64 | 64 | expect(x == 0); |
| 65 | 65 | resume p; |
| 66 | 66 | expect(x == 0); |
| ... | ... | @@ -201,7 +201,7 @@ var await_final_result: i32 = 0; |
| 201 | 201 | |
| 202 | 202 | test "coroutine await" { |
| 203 | 203 | await_seq('a'); |
| 204 | const p = async await_amain(); | |
| 204 | var p = async await_amain(); | |
| 205 | 205 | await_seq('f'); |
| 206 | 206 | resume await_a_promise; |
| 207 | 207 | await_seq('i'); |
| ... | ... | @@ -210,7 +210,7 @@ test "coroutine await" { |
| 210 | 210 | } |
| 211 | 211 | async fn await_amain() void { |
| 212 | 212 | await_seq('b'); |
| 213 | const p = async await_another(); | |
| 213 | var p = async await_another(); | |
| 214 | 214 | await_seq('e'); |
| 215 | 215 | await_final_result = await p; |
| 216 | 216 | await_seq('h'); |
| ... | ... | @@ -237,14 +237,14 @@ var early_final_result: i32 = 0; |
| 237 | 237 | |
| 238 | 238 | test "coroutine await early return" { |
| 239 | 239 | early_seq('a'); |
| 240 | const p = async early_amain(); | |
| 240 | var p = async early_amain(); | |
| 241 | 241 | early_seq('f'); |
| 242 | 242 | expect(early_final_result == 1234); |
| 243 | 243 | expect(std.mem.eql(u8, early_points, "abcdef")); |
| 244 | 244 | } |
| 245 | 245 | async fn early_amain() void { |
| 246 | 246 | early_seq('b'); |
| 247 | const p = async early_another(); | |
| 247 | var p = async early_another(); | |
| 248 | 248 | early_seq('d'); |
| 249 | 249 | early_final_result = await p; |
| 250 | 250 | early_seq('e'); |
test/stage1/behavior/await_struct.zig+2-2| ... | ... | @@ -11,7 +11,7 @@ var await_final_result = Foo{ .x = 0 }; |
| 11 | 11 | |
| 12 | 12 | test "coroutine await struct" { |
| 13 | 13 | await_seq('a'); |
| 14 | const p = async await_amain(); | |
| 14 | var p = async await_amain(); | |
| 15 | 15 | await_seq('f'); |
| 16 | 16 | resume await_a_promise; |
| 17 | 17 | await_seq('i'); |
| ... | ... | @@ -20,7 +20,7 @@ test "coroutine await struct" { |
| 20 | 20 | } |
| 21 | 21 | async fn await_amain() void { |
| 22 | 22 | await_seq('b'); |
| 23 | const p = async await_another(); | |
| 23 | var p = async await_another(); | |
| 24 | 24 | await_seq('e'); |
| 25 | 25 | await_final_result = await p; |
| 26 | 26 | await_seq('h'); |