stage2: support dbg_stmt at comptime

This commit is contained in:
Andrew Kelley
2020-09-01 23:23:29 -07:00
parent 90ace40e07
commit 12ce6eb8f6
2 changed files with 8 additions and 4 deletions

View File

@@ -643,8 +643,12 @@ fn analyzeInstBreakVoid(mod: *Module, scope: *Scope, inst: *zir.Inst.BreakVoid)
}
fn analyzeInstDbgStmt(mod: *Module, scope: *Scope, inst: *zir.Inst.NoOp) InnerError!*Inst {
const b = try mod.requireRuntimeBlock(scope, inst.base.src);
return mod.addNoOp(b, inst.base.src, Type.initTag(.void), .dbg_stmt);
if (scope.cast(Scope.Block)) |b| {
if (!b.is_comptime) {
return mod.addNoOp(b, inst.base.src, Type.initTag(.void), .dbg_stmt);
}
}
return mod.constVoid(scope, inst.base.src);
}
fn analyzeInstDeclRefStr(mod: *Module, scope: *Scope, inst: *zir.Inst.DeclRefStr) InnerError!*Inst {

View File

@@ -973,8 +973,8 @@ pub fn addCases(ctx: *TestContext) !void {
\\comptime {
\\ _ = foo;
\\}
\\extern var foo;
, &[_][]const u8{":2:5: error: unable to resolve comptime value"});
\\extern var foo: i32;
, &[_][]const u8{":2:9: error: unable to resolve comptime value"});
case.addError(
\\export fn entry() void {
\\ _ = foo;