parent
3c1f9baff1
commit
c84548e71d
@ -9874,6 +9874,7 @@ static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) {
|
||||
if (!const_val)
|
||||
return ira->codegen->builtin_types.entry_invalid;
|
||||
|
||||
assert(const_val->data.x_type != nullptr);
|
||||
return const_val->data.x_type;
|
||||
}
|
||||
|
||||
@ -16880,7 +16881,9 @@ static ZigType *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstruction
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
ir_add_error(ira, &instruction->base, buf_sprintf("found compile log statement"));
|
||||
// Here we bypass higher level functions such as ir_add_error because we do not want
|
||||
// invalidate_exec to be called.
|
||||
add_node_error(ira->codegen, instruction->base.source_node, buf_sprintf("found compile log statement"));
|
||||
|
||||
ir_build_const_from(ira, &instruction->base);
|
||||
return ira->codegen->builtin_types.entry_void;
|
||||
|
@ -1,6 +1,20 @@
|
||||
const tests = @import("tests.zig");
|
||||
|
||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
cases.add(
|
||||
"compile log statement inside function which must be comptime evaluated",
|
||||
\\fn Foo(comptime T: type) type {
|
||||
\\ @compileLog(@typeName(T));
|
||||
\\ return T;
|
||||
\\}
|
||||
\\export fn entry() void {
|
||||
\\ _ = Foo(i32);
|
||||
\\ _ = @typeName(Foo(i32));
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:2:5: error: found compile log statement",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"comptime slice of an undefined slice",
|
||||
\\comptime {
|
||||
@ -3472,11 +3486,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\}
|
||||
,
|
||||
".tmp_source.zig:5:5: error: found compile log statement",
|
||||
".tmp_source.zig:2:17: note: called from here",
|
||||
".tmp_source.zig:6:5: error: found compile log statement",
|
||||
".tmp_source.zig:2:17: note: called from here",
|
||||
".tmp_source.zig:7:5: error: found compile log statement",
|
||||
".tmp_source.zig:2:17: note: called from here",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
|
Loading…
x
Reference in New Issue
Block a user