astgen: add builtins, fn_proto exprs, extern fn, scope threading

Port multiple features from AstGen.zig:
- fnProtoExpr/fnProtoExprInner: function types as expressions
- arrayTypeSentinelExpr: [N:sentinel]T array types
- Extern fn_decl without body (implicit CCC)
- 12 builtins: ptrFromInt, Vector, setRuntimeSafety, intFromError,
  clz, branchHint, bitSizeOf, fieldParentPtr, splat, offsetOf,
  inComptime, errorFromInt, errorCast alias
- Fix namespace scope parent: use caller's scope instead of gz->base,
  allowing inner structs to reference outer locals (fixes S2, name, U)
- Fix addFunc/addFuncFancy: don't emit src_locs when body is empty

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 16:59:34 +00:00
parent 7809bdf961
commit 2cc1bd4ddc
2 changed files with 706 additions and 84 deletions

View File

@@ -297,11 +297,7 @@ fn expectEqualZir(gpa: Allocator, ref: Zir, got: c.Zir) !void {
const got_tag: u8 = @intCast(got.inst_tags[i]);
if (ref_tag != got_tag) {
std.debug.print("first divergence at [{d}]: ref_tag={d} got_tag={d}\n", .{ i, ref_tag, got_tag });
// Show ref instruction data for this position.
const rd = ref_datas[i];
std.debug.print(" ref pl_node: src_node={d} payload={d}\n", .{
rd.pl_node.src_node, rd.pl_node.payload_index,
});
// Data printing skipped to avoid tagged union safety panics.
// Scan for nearest declaration.
var j: usize = i;
while (j > 0) {