diff --git a/src/AstGen.zig b/src/AstGen.zig index ef6bf2e7da..5113ddfb8f 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -7940,7 +7940,9 @@ fn builtinCall( }, .src => { - maybeAdvanceSourceCursorToMainToken(gz, node); + const token_starts = tree.tokens.items(.start); + const node_start = token_starts[tree.firstToken(node)]; + astgen.advanceSourceCursor(node_start); const result = try gz.addExtendedPayload(.builtin_src, Zir.Inst.Src{ .node = gz.nodeIndexToRelative(node), .line = astgen.source_line, diff --git a/src/Autodoc.zig b/src/Autodoc.zig index 04b13c3026..4d13416e1f 100644 --- a/src/Autodoc.zig +++ b/src/Autodoc.zig @@ -2129,7 +2129,15 @@ fn walkInstruction( file, parent_scope, parent_src, - getBlockInlineBreak(file.zir, inst_index), + getBlockInlineBreak(file.zir, inst_index) orelse { + const res = DocData.WalkResult{ .expr = .{ + .comptimeExpr = self.comptime_exprs.items.len, + } }; + try self.comptime_exprs.append(self.arena, .{ + .code = "if (...) { ... }", + }); + return res; + }, need_type, ); }, @@ -3155,7 +3163,7 @@ fn walkDecls( 2 => { // decl test const decl_being_tested = scope.resolveDeclName(doc_comment_index); - const func_index = getBlockInlineBreak(file.zir, value_index); + const func_index = getBlockInlineBreak(file.zir, value_index).?; const pl_node = data[Zir.refToIndex(func_index).?].pl_node; const fn_src = try self.srcLocInfo(file, pl_node.src_node, decl_src); @@ -4301,12 +4309,13 @@ fn walkRef( } } -fn getBlockInlineBreak(zir: Zir, inst_index: usize) Zir.Inst.Ref { +fn getBlockInlineBreak(zir: Zir, inst_index: usize) ?Zir.Inst.Ref { const tags = zir.instructions.items(.tag); const data = zir.instructions.items(.data); const pl_node = data[inst_index].pl_node; const extra = zir.extraData(Zir.Inst.Block, pl_node.payload_index); const break_index = zir.extra[extra.end..][extra.data.body_len - 1]; + if (tags[break_index] == .condbr_inline) return null; std.debug.assert(tags[break_index] == .break_inline); return data[break_index].@"break".operand; }