parent
22e39e1e5a
commit
ac0cda8df8
@ -4069,6 +4069,7 @@ static void define_local_param_variables(CodeGen *g, ZigFn *fn_table_entry) {
|
||||
}
|
||||
|
||||
bool resolve_inferred_error_set(CodeGen *g, ZigType *err_set_type, AstNode *source_node) {
|
||||
assert(err_set_type->id == ZigTypeIdErrorSet);
|
||||
ZigFn *infer_fn = err_set_type->data.error_set.infer_fn;
|
||||
if (infer_fn != nullptr) {
|
||||
if (infer_fn->anal_state == FnAnalStateInvalid) {
|
||||
|
12
src/ir.cpp
12
src/ir.cpp
@ -12469,10 +12469,22 @@ static ZigType *ir_analyze_merge_error_sets(IrAnalyze *ira, IrInstructionBinOp *
|
||||
if (type_is_invalid(op1_type))
|
||||
return ira->codegen->builtin_types.entry_invalid;
|
||||
|
||||
if (op1_type->id != ZigTypeIdErrorSet) {
|
||||
ir_add_error(ira, instruction->op1,
|
||||
buf_sprintf("expected error set type, found '%s'", buf_ptr(&op1_type->name)));
|
||||
return ira->codegen->builtin_types.entry_invalid;
|
||||
}
|
||||
|
||||
ZigType *op2_type = ir_resolve_type(ira, instruction->op2->other);
|
||||
if (type_is_invalid(op2_type))
|
||||
return ira->codegen->builtin_types.entry_invalid;
|
||||
|
||||
if (op2_type->id != ZigTypeIdErrorSet) {
|
||||
ir_add_error(ira, instruction->op2,
|
||||
buf_sprintf("expected error set type, found '%s'", buf_ptr(&op2_type->name)));
|
||||
return ira->codegen->builtin_types.entry_invalid;
|
||||
}
|
||||
|
||||
if (type_is_global_error_set(op1_type) ||
|
||||
type_is_global_error_set(op2_type))
|
||||
{
|
||||
|
@ -1,6 +1,19 @@
|
||||
const tests = @import("tests.zig");
|
||||
|
||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
cases.add(
|
||||
"non error sets used in merge error sets operator",
|
||||
\\export fn foo() void {
|
||||
\\ const Errors = u8 || u16;
|
||||
\\}
|
||||
\\export fn bar() void {
|
||||
\\ const Errors = error{} || u16;
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:2:20: error: expected error set type, found 'u8'",
|
||||
".tmp_source.zig:5:31: error: expected error set type, found 'u16'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"variable initialization compile error then referenced",
|
||||
\\fn Undeclared() type {
|
||||
|
Loading…
x
Reference in New Issue
Block a user