Repository navigation
Stop property tests from flaking on if/in as variable names - #342
Conversation
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. Next included review available in 5 minutes. View limit details
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Reserved identifier filtering tests/property/error-handling-assignment.prop.test.ts, tests/property/generators/primitives.ts, tests/property/option-separation.prop.test.ts |
Assignment-error generators use non-reserved identifiers. Variable-list and option-separation generators exclude if and in. |
Macro reference format tests/property/formatter-source-preservation.prop.test.ts |
The global macro reference generator now produces $name references instead of bare names. |
Estimated code review effort: 2 (Simple) | ~5 minutes
Change: Bug fix
Merge Risk: 
Minimal · previous review 3f0bb
-
No actionable merge-blocking risk remains in these property-test generator updates.
Pre-merge checks: 
5
-
Full details: Docstring Coverage
-
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 4 files.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
In Stata, if and in after a command start a qualifier, so generators that emit them as variable names build invalid source and flake. - option-separation: filter RESERVED_QUALIFIER_KEYWORDS from arbitrary_variable_name (CI counterexample: generate if = ...). - error-handling-assignment: use arbitrary_non_reserved_identifier. - primitives: arbitrary_varlist excludes if/in (diagnostic-accuracy Property 13 failed on 'drop x if'). - formatter-source-preservation: restore the $ in global_macro_ref, lost in 8f06506; without it the test emitted bare identifiers.
3f0bb21 to
f700e47
Compare
option-separation's "embedded commas" property failed once in CI on #341 with the counterexamplegenerate if = max(a, _), nolabel. In Stata,ifandinright after a command start a qualifier, so that line isn't an assignment and the parser correctly returns no expression. The bug was in the test's generator, not the parser.The fix keeps
if/inout of generated variable names wherever they'd land in that position. A sweep oftests/property/turned up three more tests with the same bug. I reproduced each one by feeding it anif/ininput:arbitrary_variable_name()now filters outRESERVED_QUALIFIER_KEYWORDS. This one generator feeds all five properties in the file.arbitrary_non_reserved_identifier(). Withgen if =, the parser reads=as the start of theifqualifier, so the expected missing-expression error never appears.arbitrary_varlist(): now excludesif/in. diagnostic-accuracy Property 13 ("no false positives") failed ondrop x if.global_macro_refhad lost its$in 8f06506, so it produced bare identifiers. Withdisplay if, AST mode prints onlydisplay. I restored the$and confirmed that$ifand$inpass in both formatter modes.Verification
examplesoption fails onmain.generate if = ...onmainwith no help. With the fix, the same 200k runs pass.arbitrary_varlist()andarbitrary_non_reserved_identifier()produced noif/in.Gates, each run on its own:
check:line-endings,typecheckandlintpass.bun test ./testsgives 8172 pass and 2 fail; both failures are the help-topic tests that need a local Stata install.Not changed (the sweep found these but they're unconfirmed or out of scope):
if-condition operand namedinwould end the condition early. That's possibly the same class of bug, but I haven't reproduced it.arbitrary_command_name(): falls back toarbitrary_identifier(), so the command itself can beiforin.if/inbut probably still pass, given what they assert.Reviewed with sol-loop: 1 round with gpt-6.1-sol. Sol verdict: approved
Created with Claude Opus 5.5 in Claude Code (T3 Code).