mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
Revert "Sema: forbid @breakpoint from being called at comptime"
This reverts commit f88b523065.
Let's please go through the language proposal process for this change. I
don't see any justification for this breaking change even in the commit
message.
This commit is contained in:
parent
f88b523065
commit
3d23ba9c35
4 changed files with 25 additions and 28 deletions
11
src/Sema.zig
11
src/Sema.zig
|
|
@ -1292,7 +1292,9 @@ fn analyzeBodyInner(
|
|||
continue;
|
||||
},
|
||||
.breakpoint => {
|
||||
try sema.zirBreakpoint(block, extended);
|
||||
if (!block.is_comptime) {
|
||||
_ = try block.addNoOp(.breakpoint);
|
||||
}
|
||||
i += 1;
|
||||
continue;
|
||||
},
|
||||
|
|
@ -5618,13 +5620,6 @@ fn zirTrap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir.In
|
|||
return always_noreturn;
|
||||
}
|
||||
|
||||
fn zirBreakpoint(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void {
|
||||
const src = LazySrcLoc.nodeOffset(@bitCast(extended.operand));
|
||||
if (block.is_comptime)
|
||||
return sema.fail(block, src, "encountered @breakpoint at comptime", .{});
|
||||
_ = try block.addNoOp(.breakpoint);
|
||||
}
|
||||
|
||||
fn zirLoop(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
|
||||
const tracy = trace(@src());
|
||||
defer tracy.end();
|
||||
|
|
|
|||
9
test/cases/compile_errors/@trap_comptime_call.zig
Normal file
9
test/cases/compile_errors/@trap_comptime_call.zig
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
export fn entry() void {
|
||||
comptime @trap();
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :2:14: error: encountered @trap at comptime
|
||||
13
test/cases/compile_errors/panic_called_at_compile_time.zig
Normal file
13
test/cases/compile_errors/panic_called_at_compile_time.zig
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
export fn entry() void {
|
||||
comptime {
|
||||
@panic(
|
||||
"aoeu",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :3:9: error: encountered @panic at comptime
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
test "comptime @panic call" {
|
||||
comptime @panic("amogus");
|
||||
}
|
||||
|
||||
test "comptime @trap call" {
|
||||
comptime @trap();
|
||||
}
|
||||
|
||||
test "comptime @breakpoint call" {
|
||||
comptime @breakpoint();
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
// is_test=true
|
||||
//
|
||||
// :2:14: error: encountered @panic at comptime
|
||||
// :6:14: error: encountered @trap at comptime
|
||||
// :10:14: error: encountered @breakpoint at comptime
|
||||
Loading…
Add table
Reference in a new issue