Skip to content

Commit 146d4fb

Browse files
committed
improve type safety of std.zig.Ast
This commits adds the following distinct integer types to std.zig.Ast: - OptionalTokenIndex - TokenOffset - OptionalTokenOffset - Node.OptionalIndex - Node.Offset - Node.OptionalOffset The `Node.Index` type has also been converted to a distinct type while TokenIndex remains unchanged. `Ast.Node.Data.Item` has also been changed to a (untagged) union to provide safety checks.
1 parent 031ee48 commit 146d4fb

24 files changed

+4024
-4221
lines changed

lib/compiler/aro_translate_c/ast.zig

Lines changed: 253 additions & 238 deletions
Large diffs are not rendered by default.

lib/compiler/reduce.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ pub fn main() !void {
220220
mem.eql(u8, msg, "unused function parameter") or
221221
mem.eql(u8, msg, "unused capture"))
222222
{
223-
const ident_token = item.data.token;
223+
const ident_token = item.data.token.unwrap().?;
224224
try more_fixups.unused_var_decls.put(gpa, ident_token, {});
225225
} else {
226226
std.debug.print("found other ZIR error: '{s}'\n", .{msg});

0 commit comments

Comments
 (0)