Port tests:
- "alignment in anonymous literal"
- "'zig fmt: (off|on)' can be surrounded by arbitrary whitespace"
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests:
- "line and doc comment following 'zig fmt: off'"
- "doc and line comment following 'zig fmt: off'"
- "line comment following 'zig fmt: on'"
- "doc comment following 'zig fmt: on'"
- "line and doc comment following 'zig fmt: on'"
- "doc and line comment following 'zig fmt: on'"
- "block in slice expression"
- "defer"
Fix defer node data: body goes in lhs (not rhs) to match .node
union variant.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests:
- "alignment"
- "C main"
- "return"
- "arrays"
- "blocks"
- "container doc comments"
- "comments before global variables"
- "comments before test decl"
- "decimal float literals with underscore separators"
- "comptime"
- "comptime block in container"
- "comments before var decl in struct"
- "block with same line comment after end brace"
- "comment after empty comment"
- "comment after params"
Fix trailing flag for comptime blocks in parseContainerMembers.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests:
- "threadlocal"
- "linksection"
- "addrspace"
Implement full var decl proto with aligned_var_decl, local_var_decl,
and global_var_decl node types for align/addrspace/linksection.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests:
- "pointer-to-one with modifiers"
- "pointer-to-many with modifiers"
- "sentinel pointer with modifiers"
- "c pointer with modifiers"
- "slice with modifiers"
- "sentinel slice with modifiers"
- "allowzero pointer"
Implement in parser.c:
- parsePtrModifiersAndType: shared pointer modifier parsing with
align(expr:expr:expr) bit-range, addrspace, sentinel support
- ptr_type, ptr_type_bit_range nodes with proper OptionalIndex
encoding via global OPT() macro
- Refactor * and [*] pointer type parsing to use shared code
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- "sentinel array literal 1 element"
- "anon literal in array"
- "Unicode code point literal larger than u8"
- "slices with spaces in bounds"
- "C pointers"
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Implement in parser.c:
- defer and errdefer statements with expectBlockExprStatement
- parseAssignExpr for assignment expressions (expr op= expr)
- expectBlockExprStatement: block or assign expr + semicolon
- assignOpTag: map all assignment operator tokens to AST tags
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests from upstream parser_test.zig:
- "multiline string with backslash at end of line"
- "multiline string parameter in fn call with trailing comma"
- "trailing comma on fn call"
- "multi line arguments without last comma"
- "empty block with only comment"
- "trailing commas on struct decl"
- "extra newlines at the end"
- "nested struct literal with one item"
- "if-else with comment before else"
Fix parseSuffixExpr: continue suffix loop after call parsing
instead of returning, enabling method chains like a.b().c().
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests from upstream parser_test.zig:
- "if statement"
- "respect line breaks in if-else"
- "if nested"
- "remove empty lines at start/end of block"
Implement in parser.c:
- parseIfExpr: if/else expression parsing with payloads
- parsePtrPayload, parsePayload: |value| and |*value| handling
- Handle block-terminated expressions without semicolons in
expectVarDeclExprStatement
Fix zigData in parser_test.zig:
- if, while, while_cont use node_and_extra (not node_and_node)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests from upstream parser_test.zig:
- "respect line breaks after infix operators"
- "fn decl with trailing comma"
- "enum decl with no trailing comma"
- "struct literal no trailing comma"
- "2nd arg multiline string"
- "final arg multiline string"
- "function call with multiline argument"
No new parser.c changes needed — all features already implemented.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests from upstream parser_test.zig:
- "comment to disable/enable zig fmt"
- "line comment following 'zig fmt: off'"
- "doc comment following 'zig fmt: off'"
- "alternating 'zig fmt: off' and 'zig fmt: on'"
- "spaces around slice operator"
Fix parsePrimaryTypeExpr: don't reject identifier followed by colon;
the colon may be part of slice sentinel syntax, not a label.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests from upstream parser_test.zig:
- "trailing comma in fn parameter list" (all combinations)
- "enum literal inside array literal"
- "builtin call with trailing comma"
Implement in parser.c:
- parseParamDeclList: full parameter parsing with names, comptime,
noalias, doc comments, varargs
- parseFnProto: fn_proto_multi, fn_proto_one, fn_proto with
align/addrspace/section/callconv
- parseSuffixExpr: function call with arguments
- parsePrimaryExpr: return, comptime, nosuspend, resume expressions
- parseAddrSpace, parseLinkSection, parseCallconv: full parsing
- Use OPT() macro for OptionalIndex encoding in extra data
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests from upstream parser_test.zig:
- "slices" (open, closed, sentinel-terminated)
- "tagged union with enum values"
- "tagged union enum tag last token"
Implement in parser.c:
- Slice expressions in parseSuffixOp: slice_open, slice,
slice_sentinel
- Handle OptionalIndex encoding for absent slice end expr
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests from upstream parser_test.zig:
- "struct literal 2/3 element" (with and without comma)
- "anon list literal 1/2/3 element" (with and without comma)
- "array literal 0/1/2/3 element" (with and without comma)
All 17 new tests pass without parser changes — the init list
implementation from the previous commit handles all cases.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests from upstream parser_test.zig:
- "allow empty line before comment at start of block"
- "comptime struct field"
- "break from block"
- "grouped expressions (parentheses)"
- "array types last token"
Fix bugs in parser.c:
- parseBreakLabel: use null_token instead of null_node
- test decl: use null_token for unnamed tests
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests from upstream parser_test.zig:
- "container declaration, one item, multi line trailing comma"
- "container declaration, no trailing comma on separate line"
- "container declaration, line break, no trailing comma"
- "container declaration, transform trailing comma"
- "container declaration, comment, add trailing comma"
- "container declaration, multiline string, add trailing comma"
- "container declaration, doc comment on member, add trailing comma"
- "remove empty lines at start/end of container decl"
Implement in parser.c:
- Test declarations in parseContainerMembers
- Comptime block/var statements in expectStatement
- Variable declaration with initializer in expectVarDeclExprStatement
- Regular assignment expressions
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests from upstream parser_test.zig:
- "multiline string mixed with comments"
- "empty file"
- "file ends in comment"
- "file ends in multi line comment"
- "file ends in comment after var decl"
- "top-level fields"
- "container declaration, single line"
Implement in parser.c:
- parseSuffixOp: array access, field access, deref, unwrap optional
- Slice/array type parsing in parseTypeExpr
- Multiline string literal parsing
Fix zigData mapping in parser_test.zig:
- optional_type uses .node (not .opt_node)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests from upstream parser_test.zig:
- "respect line breaks before functions"
- "simple top level comptime block"
- "two spaced line comments before decl"
- "respect line breaks after var declarations"
Implement in parser.c:
- parseSuffixOp: array access (a[i]), field access (a.b),
deref (a.*), unwrap optional (a.?)
- Multiline string literal parsing
- Slice types ([]T, [:s]T) and array types ([N]T, [N:s]T)
- Fix comptime block main_token in parseContainerMembers
Fix zigData mapping in parser_test.zig:
- field_access, unwrap_optional use node_and_token (not node_and_node)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port "zig fmt: respect line breaks in struct field value declaration"
test from upstream parser_test.zig.
Implement in parser.c:
- Slice types ([]T, [:s]T) in parseTypeExpr
- Array types ([N]T, [N:s]T) in parseTypeExpr
- Multiline string literals in parsePrimaryTypeExpr
- Add comments explaining why const/volatile/allowzero pointer
modifiers are consumed (not stored in AST; renderer re-derives
them from token positions)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>