astgen: fix int_type signedness and struct layout

Match Zig's Signedness enum values (unsigned=1, signed=0) and
reorder int_type struct fields to match Zig's layout:
[src_node, bit_count, signedness, pad].

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-13 20:28:25 +00:00
parent 21ff7395ab
commit b3d106ec97
3 changed files with 5 additions and 4 deletions

View File

@@ -2668,7 +2668,8 @@ static uint32_t tryResolvePrimitiveIdent(GenZir* gz, uint32_t node) {
// Integer type detection: u29, i13, etc. (AstGen.zig:8304-8336).
if (tok_len >= 2
&& (source[tok_start] == 'u' || source[tok_start] == 'i')) {
uint8_t signedness = (source[tok_start] == 'i') ? 1 : 0;
// Zig Signedness enum: unsigned=1, signed=0
uint8_t signedness = (source[tok_start] == 'u') ? 1 : 0;
uint16_t bit_count = 0;
bool valid = true;
for (uint32_t k = tok_start + 1; k < tok_end; k++) {

View File

@@ -798,8 +798,8 @@ test "astgen: corpus tokenizer_test.zig" {
}
test "astgen: corpus parser_test.zig" {
// TODO: int_type signedness data mismatch at inst[6899] — all tags and
// inst_len match, but one int_type has ref=signed got=unsigned.
// TODO: 10+ extra data mismatches (ref=48 got=32, bit 4 = propagate_error_trace)
// in call instruction flags — ctx propagation differs from upstream.
if (true) return error.SkipZigTest;
const gpa = std.testing.allocator;
try corpusCheck(gpa, @embedFile("parser_test.zig"));

2
zir.h
View File

@@ -384,9 +384,9 @@ typedef union {
} ptr_type;
struct {
int32_t src_node;
uint16_t bit_count;
uint8_t signedness;
uint8_t _pad;
uint16_t bit_count;
} int_type;
struct {
int32_t src_node;