parent
09cc1dc660
commit
901b5c1566
|
@ -3242,6 +3242,13 @@ static void add_top_level_decl(CodeGen *g, ScopeDecls *decls_scope, Tld *tld) {
|
|||
} else if (tld->id == TldIdFn) {
|
||||
assert(tld->source_node->type == NodeTypeFnProto);
|
||||
is_export = tld->source_node->data.fn_proto.is_export;
|
||||
|
||||
if (!is_export && !tld->source_node->data.fn_proto.is_extern &&
|
||||
tld->source_node->data.fn_proto.fn_def_node == nullptr)
|
||||
{
|
||||
add_node_error(g, tld->source_node, buf_sprintf("non-extern function has no body"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (is_export) {
|
||||
g->resolve_queue.append(tld);
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
const tests = @import("tests.zig");
|
||||
|
||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
cases.add(
|
||||
"function protoype with no body",
|
||||
\\fn foo() void;
|
||||
\\export fn entry() void {
|
||||
\\ foo();
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:1:1: error: non-extern function has no body",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"@typeInfo causing depend on itself compile error",
|
||||
\\const start = struct {
|
||||
|
|
Loading…
Reference in New Issue