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:
Andrew Kelley 2023-12-11 12:24:15 -07:00
parent f88b523065
commit 3d23ba9c35
4 changed files with 25 additions and 28 deletions

View file

@ -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();

View file

@ -0,0 +1,9 @@
export fn entry() void {
comptime @trap();
}
// error
// backend=stage2
// target=native
//
// :2:14: error: encountered @trap at comptime

View file

@ -0,0 +1,13 @@
export fn entry() void {
comptime {
@panic(
"aoeu",
);
}
}
// error
// backend=stage2
// target=native
//
// :3:9: error: encountered @panic at comptime

View file

@ -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