AstGen: fix @breakpoint ZIR

Previously it relied on the breakpoint ZIR instruction being void, but
that's no longer how things work.
This commit is contained in:
Andrew Kelley
2021-04-07 10:24:57 -07:00
parent 2871d32be7
commit bcc371618f
2 changed files with 11 additions and 2 deletions

View File

@@ -3894,11 +3894,11 @@ fn builtinCall(
return rvalue(gz, scope, rl, result, node);
},
.breakpoint => {
const result = try gz.add(.{
_ = try gz.add(.{
.tag = .breakpoint,
.data = .{ .node = gz.astgen.decl.nodeIndexToRelative(node) },
});
return rvalue(gz, scope, rl, result, node);
return rvalue(gz, scope, rl, .void_value, node);
},
.import => {
const target = try expr(gz, scope, .none, params[0]);

View File

@@ -280,6 +280,15 @@ pub fn addCases(ctx: *TestContext) !void {
\\}
, "");
// If expression with breakpoint that does not get hit
case.addCompareOutput(
\\export fn main() c_int {
\\ var x: i32 = 1;
\\ if (x != 1) @breakpoint();
\\ return 0;
\\}
, "");
// Switch expression
case.addCompareOutput(
\\export fn main() c_int {