parent
d49d6f0cde
commit
8fd7cc11e1
|
@ -1022,6 +1022,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
|
|||
ensure_complete_type(g, fn_type_id->return_type);
|
||||
if (type_is_invalid(fn_type_id->return_type))
|
||||
return g->builtin_types.entry_invalid;
|
||||
assert(fn_type_id->return_type->id != TypeTableEntryIdOpaque);
|
||||
} else {
|
||||
zig_panic("TODO implement inferred return types https://github.com/ziglang/zig/issues/447");
|
||||
}
|
||||
|
|
|
@ -18676,6 +18676,11 @@ static TypeTableEntry *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruc
|
|||
fn_type_id.return_type = ir_resolve_type(ira, return_type_value);
|
||||
if (type_is_invalid(fn_type_id.return_type))
|
||||
return ira->codegen->builtin_types.entry_invalid;
|
||||
if (fn_type_id.return_type->id == TypeTableEntryIdOpaque) {
|
||||
ir_add_error(ira, instruction->return_type,
|
||||
buf_sprintf("return type cannot be opaque"));
|
||||
return ira->codegen->builtin_types.entry_invalid;
|
||||
}
|
||||
|
||||
if (fn_type_id.cc == CallingConventionAsync) {
|
||||
if (instruction->async_allocator_type_value == nullptr) {
|
||||
|
|
|
@ -1,6 +1,15 @@
|
|||
const tests = @import("tests.zig");
|
||||
|
||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
cases.add(
|
||||
"use c_void as return type of fn ptr",
|
||||
\\export fn entry() void {
|
||||
\\ const a: fn () c_void = undefined;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:2:20: error: return type cannot be opaque",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"non int passed to @intToFloat",
|
||||
\\export fn entry() void {
|
||||
|
@ -9,6 +18,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
|||
,
|
||||
".tmp_source.zig:2:32: error: expected int type, found 'comptime_float'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"use implicit casts to assign null to non-nullable pointer",
|
||||
\\export fn entry() void {
|
||||
|
|
Loading…
Reference in New Issue