authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-03-09 18:38:54+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-03-09 18:43:09+02:00
log3fd2cd43678d52ca2f737d991edaddfd8b73c2a4
tree1a69d7283d69664631b6d07a87257355bb71e2eb
parent03c1431f9c0b651f3f1853f11112edc07555883d
signature Commit is signed but in an unrecognized format.

add LemonBoy's test


3 files changed, 25 insertions(+), 3 deletions(-)

src/codegen.cpp+1-1
......@@ -969,7 +969,7 @@ static Buf *panic_msg_buf(PanicMsgId msg_id) {
969969 case PanicMsgIdResumedFnPendingAwait:
970970 return buf_create_from_str("resumed an async function which can only be awaited");
971971 case PanicMsgIdBadNoAsyncCall:
972 return buf_create_from_str("async function called with noasync suspended");
972 return buf_create_from_str("async function called in noasync scope suspended");
973973 case PanicMsgIdResumeNotSuspendedFn:
974974 return buf_create_from_str("resumed a non-suspended function");
975975 case PanicMsgIdBadSentinel:
test/compile_errors.zig+8-2
......@@ -4,11 +4,17 @@ const std = @import("std");
44pub fn addCases(cases: *tests.CompileErrorContext) void {
55 cases.addTest("combination of noasync and async",
66 \\export fn entry() void {
7 \\ noasync async foo();
7 \\ noasync {
8 \\ const bar = async foo();
9 \\ suspend;
10 \\ resume bar;
11 \\ }
812 \\}
913 \\fn foo() void {}
1014 , &[_][]const u8{
11 "tmp.zig:2:13: error: async call in noasync scope",
15 "tmp.zig:3:21: error: async call in noasync scope",
16 "tmp.zig:4:9: error: suspend in noasync scope",
17 "tmp.zig:5:9: error: resume in noasync scope",
1218 });
1319
1420 cases.addTest("@TypeOf with no arguments",
test/stage1/behavior/async_fn.zig+16
......@@ -1531,3 +1531,19 @@ test "noasync await" {
15311531 S.doTheTest();
15321532 expect(S.finished);
15331533}
1534
1535test "noasync on function calls" {
1536 const S0 = struct {
1537 b: i32 = 42,
1538 };
1539 const S1 = struct {
1540 fn c() S0 {
1541 return S0{};
1542 }
1543 fn d() !S0 {
1544 return S0{};
1545 }
1546 };
1547 expectEqual(@as(i32, 42), noasync S1.c().b);
1548 expectEqual(@as(i32, 42), (try noasync S1.d()).b);
1549}