mirror of
https://github.com/ziglang/zig.git
synced 2025-12-16 11:13:08 +00:00
parent
f7670882af
commit
ad3e2a5da0
@ -1376,6 +1376,10 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
|
|||||||
fn_type_id.return_type = (fn_proto->return_type == nullptr) ?
|
fn_type_id.return_type = (fn_proto->return_type == nullptr) ?
|
||||||
g->builtin_types.entry_void : analyze_type_expr(g, child_scope, fn_proto->return_type);
|
g->builtin_types.entry_void : analyze_type_expr(g, child_scope, fn_proto->return_type);
|
||||||
|
|
||||||
|
if (type_is_invalid(fn_type_id.return_type)) {
|
||||||
|
return g->builtin_types.entry_invalid;
|
||||||
|
}
|
||||||
|
|
||||||
if (fn_type_id.cc != CallingConventionUnspecified && !type_allowed_in_extern(g, fn_type_id.return_type)) {
|
if (fn_type_id.cc != CallingConventionUnspecified && !type_allowed_in_extern(g, fn_type_id.return_type)) {
|
||||||
add_node_error(g, fn_proto->return_type,
|
add_node_error(g, fn_proto->return_type,
|
||||||
buf_sprintf("return type '%s' not allowed in function with calling convention '%s'",
|
buf_sprintf("return type '%s' not allowed in function with calling convention '%s'",
|
||||||
@ -1386,7 +1390,7 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
|
|||||||
|
|
||||||
switch (fn_type_id.return_type->id) {
|
switch (fn_type_id.return_type->id) {
|
||||||
case TypeTableEntryIdInvalid:
|
case TypeTableEntryIdInvalid:
|
||||||
return g->builtin_types.entry_invalid;
|
zig_unreachable();
|
||||||
|
|
||||||
case TypeTableEntryIdUndefLit:
|
case TypeTableEntryIdUndefLit:
|
||||||
case TypeTableEntryIdNullLit:
|
case TypeTableEntryIdNullLit:
|
||||||
|
|||||||
@ -1,6 +1,10 @@
|
|||||||
const tests = @import("tests.zig");
|
const tests = @import("tests.zig");
|
||||||
|
|
||||||
pub fn addCases(cases: &tests.CompileErrorContext) void {
|
pub fn addCases(cases: &tests.CompileErrorContext) void {
|
||||||
|
cases.add("function with invalid return type",
|
||||||
|
\\export fn foo() boid {}
|
||||||
|
, ".tmp_source.zig:1:17: error: use of undeclared identifier 'boid'");
|
||||||
|
|
||||||
cases.add("function with non-extern enum parameter",
|
cases.add("function with non-extern enum parameter",
|
||||||
\\const Foo = enum { A, B, C };
|
\\const Foo = enum { A, B, C };
|
||||||
\\export fn entry(foo: Foo) void { }
|
\\export fn entry(foo: Foo) void { }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user