| author | |
| committer | |
| log | 1254a453b91623849dcb0a655b1212c9a179d29a |
| tree | d592ff434b8be7b7285479b9a49bc2f1c7211ff7 |
| parent | 49c88e23af6fe1dc895544f91231cc3b53110c8e |
| signature |
See #30633 files changed, 21 insertions(+), 0 deletions(-)
src/analyze.cpp+2| ... | ... | @@ -5197,6 +5197,8 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) { |
| 5197 | 5197 | return ErrorNone; |
| 5198 | 5198 | |
| 5199 | 5199 | ZigFn *fn = frame_type->data.frame.fn; |
| 5200 | assert(!fn->type_entry->data.fn.is_generic); | |
| 5201 | ||
| 5200 | 5202 | switch (fn->anal_state) { |
| 5201 | 5203 | case FnAnalStateInvalid: |
| 5202 | 5204 | return ErrorSemanticAnalyzeFail; |
src/ir.cpp+6| ... | ... | @@ -22095,6 +22095,12 @@ static IrInstruction *ir_analyze_instruction_frame_type(IrAnalyze *ira, IrInstru |
| 22095 | 22095 | if (fn == nullptr) |
| 22096 | 22096 | return ira->codegen->invalid_instruction; |
| 22097 | 22097 | |
| 22098 | if (fn->type_entry->data.fn.is_generic) { | |
| 22099 | ir_add_error(ira, &instruction->base, | |
| 22100 | buf_sprintf("@Frame() of generic function")); | |
| 22101 | return ira->codegen->invalid_instruction; | |
| 22102 | } | |
| 22103 | ||
| 22098 | 22104 | ZigType *ty = get_fn_frame_type(ira->codegen, fn); |
| 22099 | 22105 | return ir_const_type(ira, &instruction->base, ty); |
| 22100 | 22106 | } |
test/compile_errors.zig+13| ... | ... | @@ -2,6 +2,18 @@ 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 | "@Frame() of generic function", | |
| 7 | \\export fn entry() void { | |
| 8 | \\ var frame: @Frame(func) = undefined; | |
| 9 | \\} | |
| 10 | \\fn func(comptime T: type) void { | |
| 11 | \\ var x: T = undefined; | |
| 12 | \\} | |
| 13 | , | |
| 14 | "tmp.zig:2:16: error: @Frame() of generic function", | |
| 15 | ); | |
| 16 | ||
| 5 | 17 | cases.add( |
| 6 | 18 | "@frame() causes function to be async", |
| 7 | 19 | \\export fn entry() void { |
| ... | ... | @@ -14,6 +26,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 14 | 26 | "tmp.zig:1:1: error: function with calling convention 'ccc' cannot be async", |
| 15 | 27 | "tmp.zig:5:9: note: @frame() causes function to be async", |
| 16 | 28 | ); |
| 29 | ||
| 17 | 30 | cases.add( |
| 18 | 31 | "invalid suspend in exported function", |
| 19 | 32 | \\export fn entry() void { |