| author | |
| committer | |
| log | c84548e71d4990352c202da92d47f1398385411f |
| tree | a4c4ee25ba2708c1c3ffb92a9942cff58bfa1677 |
| parent | 3c1f9baff10be20910fc6e168c293759d9b8537e |
| signature |
closes #14592 files changed, 18 insertions(+), 4 deletions(-)
src/ir.cpp+4-1| ... | ... | @@ -9874,6 +9874,7 @@ static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) { |
| 9874 | 9874 | if (!const_val) |
| 9875 | 9875 | return ira->codegen->builtin_types.entry_invalid; |
| 9876 | 9876 | |
| 9877 | assert(const_val->data.x_type != nullptr); | |
| 9877 | 9878 | return const_val->data.x_type; |
| 9878 | 9879 | } |
| 9879 | 9880 | |
| ... | ... | @@ -16880,7 +16881,9 @@ static ZigType *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstruction |
| 16880 | 16881 | } |
| 16881 | 16882 | fprintf(stderr, "\n"); |
| 16882 | 16883 | |
| 16883 | ir_add_error(ira, &instruction->base, buf_sprintf("found compile log statement")); | |
| 16884 | // Here we bypass higher level functions such as ir_add_error because we do not want | |
| 16885 | // invalidate_exec to be called. | |
| 16886 | add_node_error(ira->codegen, instruction->base.source_node, buf_sprintf("found compile log statement")); | |
| 16884 | 16887 | |
| 16885 | 16888 | ir_build_const_from(ira, &instruction->base); |
| 16886 | 16889 | return ira->codegen->builtin_types.entry_void; |
test/compile_errors.zig+14-3| ... | ... | @@ -1,6 +1,20 @@ |
| 1 | 1 | const tests = @import("tests.zig"); |
| 2 | 2 | |
| 3 | 3 | pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 4 | cases.add( | |
| 5 | "compile log statement inside function which must be comptime evaluated", | |
| 6 | \\fn Foo(comptime T: type) type { | |
| 7 | \\ @compileLog(@typeName(T)); | |
| 8 | \\ return T; | |
| 9 | \\} | |
| 10 | \\export fn entry() void { | |
| 11 | \\ _ = Foo(i32); | |
| 12 | \\ _ = @typeName(Foo(i32)); | |
| 13 | \\} | |
| 14 | , | |
| 15 | ".tmp_source.zig:2:5: error: found compile log statement", | |
| 16 | ); | |
| 17 | ||
| 4 | 18 | cases.add( |
| 5 | 19 | "comptime slice of an undefined slice", |
| 6 | 20 | \\comptime { |
| ... | ... | @@ -3472,11 +3486,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3472 | 3486 | \\} |
| 3473 | 3487 | , |
| 3474 | 3488 | ".tmp_source.zig:5:5: error: found compile log statement", |
| 3475 | ".tmp_source.zig:2:17: note: called from here", | |
| 3476 | 3489 | ".tmp_source.zig:6:5: error: found compile log statement", |
| 3477 | ".tmp_source.zig:2:17: note: called from here", | |
| 3478 | 3490 | ".tmp_source.zig:7:5: error: found compile log statement", |
| 3479 | ".tmp_source.zig:2:17: note: called from here", | |
| 3480 | 3491 | ); |
| 3481 | 3492 | |
| 3482 | 3493 | cases.add( |