parent
49c88e23af
commit
1254a453b9
|
@ -5197,6 +5197,8 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {
|
|||
return ErrorNone;
|
||||
|
||||
ZigFn *fn = frame_type->data.frame.fn;
|
||||
assert(!fn->type_entry->data.fn.is_generic);
|
||||
|
||||
switch (fn->anal_state) {
|
||||
case FnAnalStateInvalid:
|
||||
return ErrorSemanticAnalyzeFail;
|
||||
|
|
|
@ -22095,6 +22095,12 @@ static IrInstruction *ir_analyze_instruction_frame_type(IrAnalyze *ira, IrInstru
|
|||
if (fn == nullptr)
|
||||
return ira->codegen->invalid_instruction;
|
||||
|
||||
if (fn->type_entry->data.fn.is_generic) {
|
||||
ir_add_error(ira, &instruction->base,
|
||||
buf_sprintf("@Frame() of generic function"));
|
||||
return ira->codegen->invalid_instruction;
|
||||
}
|
||||
|
||||
ZigType *ty = get_fn_frame_type(ira->codegen, fn);
|
||||
return ir_const_type(ira, &instruction->base, ty);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,18 @@ const tests = @import("tests.zig");
|
|||
const builtin = @import("builtin");
|
||||
|
||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
cases.add(
|
||||
"@Frame() of generic function",
|
||||
\\export fn entry() void {
|
||||
\\ var frame: @Frame(func) = undefined;
|
||||
\\}
|
||||
\\fn func(comptime T: type) void {
|
||||
\\ var x: T = undefined;
|
||||
\\}
|
||||
,
|
||||
"tmp.zig:2:16: error: @Frame() of generic function",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"@frame() causes function to be async",
|
||||
\\export fn entry() void {
|
||||
|
@ -14,6 +26,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
|||
"tmp.zig:1:1: error: function with calling convention 'ccc' cannot be async",
|
||||
"tmp.zig:5:9: note: @frame() causes function to be async",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"invalid suspend in exported function",
|
||||
\\export fn entry() void {
|
||||
|
|
Loading…
Reference in New Issue
Block a user