Update check_test_order.py to handle header/footer split correctly
when infrastructure code is at both start and end of file.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update test content to match upstream exactly:
- "comptime block in container"
- "comment after empty comment"
- "comment after params"
- "decimal float literals with underscore separators"
- "container doc comments"
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update test content to match upstream:
- "arrays" (full upstream test content)
- "blocks" (add labeled block and blk: variants)
- "comptime" (full upstream test with comptime var, expressions)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests:
- "destructure" (implement assign_destructure in
expectVarDeclExprStatement)
- "infix operators" (partial — orelse as discard target deferred)
- "pointer attributes" (fix ** to parse inner modifiers per upstream)
- "slice attributes" (fix sentinel+align to use ptr_type node)
Fix test bodies to match upstream verbatim:
- "block with same line comment after end brace"
- "comments before var decl in struct"
- "comments before global variables"
- "comments in statements"
- "comments before test decl"
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests:
- "pointer attributes"
- "slice attributes"
Fix ** pointer type to parse modifiers per upstream (no sentinel,
modifiers on inner pointer only).
Fix ptr_type selection when both sentinel and align are present
(use ptr_type with extra data instead of ptr_type_sentinel which
can't store alignment).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update test content to match upstream exactly:
- "block with same line comment after end brace"
- "comments before var decl in struct"
- "comments before global variables"
- "comments in statements"
- "comments before test decl"
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port 29 tests including:
- field access, multiline string, regression tests
- array formatting, function params, doc comments
- for loop payloads, switch items, saturating arithmetic
- inline for/while in expression context
- canonicalize symbols, pointer type syntax, binop indentation
Implement inline for/while in parsePrimaryExpr.
Remove unused tok variable from parsePrimaryExpr.
Deferred tests (need further work):
- "function with labeled block as return type"
- "Control flow statement as body of blockless if"
- "line comment after multiline single expr if"
- "make single-line if no trailing comma, fmt: off"
- "test indentation after equals sign" (destructuring)
- "indentation of comments within catch, else, orelse"
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests:
- "remove newlines surrounding doc comment between members within container decl (1)"
- "remove newlines surrounding doc comment between members within container decl (2)"
- "remove newlines surrounding doc comment within container decl"
- "comments with CRLF line endings"
- "else comptime expr"
- "integer literals with underscore separators"
- "hex literals with underscore separators"
- "hexadecimal float literals with underscore separators"
- "C var args"
- "Only indent multiline string literals in function calls"
- "Don't add extra newline after if"
- "comments in ternary ifs"
- "while statement in blockless if"
- "test comments in field access chain"
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests:
- "while" (full test with all variants)
- "for" (full test with all variants including testTransform)
Fix in parser.c:
- comptime var decl: don't wrap in comptime node (renderer
detects comptime from token positions)
- forPrefix: handle trailing comma in input list and capture list
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests:
- "asm expression with comptime content"
- "simple asm"
Fix asm_output to handle (identifier) operand without arrow.
Fix asm_simple zigData mapping to use node_and_token.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add AST_NODE_ASM_LEGACY for legacy string clobber format.
When asm clobbers use string literals ("clobber1", "clobber2"),
produce asm_legacy node instead of asm node.
Port tests:
- "preserves clobbers in inline asm with stray comma"
- "remove trailing comma at the end of assembly clobber"
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Checks and fixes test ordering in parser_test.zig to match
upstream zig/lib/std/zig/parser_test.zig.
Usage:
python3 check_test_order.py # check only
python3 check_test_order.py --fix # reorder tests
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Implement in parser.c:
- forPrefix: parse for input expressions and capture variables
- parseForExpr: for_simple and for AST nodes with optional else
- Handle for and while in parsePrimaryTypeExpr for top-level usage
Remove stale cppcheck knownConditionTrueFalse suppression.
Port test "top-level for/while loop".
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests:
- "error set declaration"
- "union(enum(u32)) with assigned enum values"
- "resume from suspend block"
- "comments before error set decl"
- "comments before switch prong"
- "array literal with 1 item on 1 line"
- "comments in statements"
Implement in parser.c:
- suspend statement in expectStatement
- Fix error set decl to store lbrace token (not 0)
- Fix comptime statement to wrap inner expression
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests:
- "comment after if before another if"
- "line comment between if block and else keyword"
- "same line comments in expression"
- "add comma on last switch prong"
- "same-line comment after a statement"
- "same-line comment after var decl in struct"
- "same-line comment after field decl"
- "same-line comment after switch prong"
- "same-line comment after non-block if expression"
- "same-line comment on comptime expression"
- "switch with empty body"
- "line comments in struct initializer"
- "first line comment in struct initializer"
- "doc comments before struct field"
Implement in parser.c:
- error.Value and error{...} in parsePrimaryTypeExpr
- TOKEN_PERIOD_ASTERISK (deref) in parseSuffixOp
- Fix comptime statement to wrap inner expression in comptime node
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests:
- "switch cases trailing comma"
- "slice align"
- "add trailing comma to array literal"
- "first thing in file is line comment"
- "line comment after doc comment"
- "bit field alignment"
- "nested switch"
- "float literal with exponent"
- "if-else end of comptime"
- "nested blocks"
- "statements with comment between"
- "statements with empty line between"
- "ptr deref operator and unwrap optional operator"
Fix in parser.c:
- switch_case SubRange stored via addExtra (not inline)
- Switch case body uses parseAssignExpr (not expectExpr)
- TOKEN_PERIOD_ASTERISK for deref in parseSuffixOp
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests:
- "array literal with hint"
- "array literal vertical column alignment"
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Implement parseSwitchExpr in parser.c:
- switch(expr) { cases... } with case items, ranges, else
- switch_case_one and switch_case node types
- Proper scratch management for nested case items
Port tests:
- "switch comment before prong"
- "switch comment after prong"
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests:
- "if condition has line break but must not wrap"
- "if condition has line break but must not wrap (no fn call comma)"
Implement catch payload (|err|) parsing in parseExprPrecedence.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Implement in parser.c:
- parseWhileExpr: while (cond) body, with optional payload,
continue expression, and else clause
- while_simple, while_cont, while AST nodes
Port test "while else err prong with no block".
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Split "2nd arg multiline string" to match upstream structure
(separate test for "many args" variant) and add missing
testTransform sub-case.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port tests:
- "'zig fmt: (off|on)' works in the middle of code"
- "'zig fmt: on' indentation is unchanged"
Handle block-terminated expressions (if, while) that don't need
semicolons by checking if previous token was '}'.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reorder all test blocks in parser_test.zig to match the order
they appear in the upstream zig/lib/std/zig/parser_test.zig.
Tests not in upstream ("Ast header smoke test", "my function")
are placed at the end.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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>