diff --git a/src-self-hosted/zir_sema.zig b/src-self-hosted/zir_sema.zig index 8a61178a68..676b662077 100644 --- a/src-self-hosted/zir_sema.zig +++ b/src-self-hosted/zir_sema.zig @@ -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 { diff --git a/test/stage2/test.zig b/test/stage2/test.zig index b631e37b97..ad81e463b9 100644 --- a/test/stage2/test.zig +++ b/test/stage2/test.zig @@ -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;