Skip to content

Stop property tests from flaking on if/in as variable names - #342

Merged
jbearak merged 1 commit into
mainfrom
t3/fix-property-qualifier-identifiers
Nov 1, 2026
Merged

jbearak merged 1 commit into
mainfrom
t3/fix-property-qualifier-identifiers

Conversation

@jbearak

@jbearak jbearak commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

option-separation's "embedded commas" property failed once in CI on #341 with the counterexample generate if = max(a, _), nolabel. In Stata, if and in right 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/in out of generated variable names wherever they'd land in that position. A sweep of tests/property/ turned up three more tests with the same bug. I reproduced each one by feeding it an if/in input:

  • option-separation: arbitrary_variable_name() now filters out RESERVED_QUALIFIER_KEYWORDS. This one generator feeds all five properties in the file.
  • error-handling-assignment: switched to arbitrary_non_reserved_identifier(). With gen if =, the parser reads = as the start of the if qualifier, so the expected missing-expression error never appears.
  • Shared arbitrary_varlist(): now excludes if/in. diagnostic-accuracy Property 13 ("no false positives") failed on drop x if.
  • formatter-source-preservation: global_macro_ref had lost its $ in 8f06506, so it produced bare identifiers. With display if, AST mode prints only display. I restored the $ and confirmed that $if and $in pass in both formatter modes.

Verification

  • Replaying the CI counterexample through fast-check's examples option fails on main.
  • A 200k-run stress of the property found generate if = ... on main with no help. With the fix, the same 200k runs pass.
  • Each changed file passes 10 out of 10 runs.
  • Sampling 300k values each from arbitrary_varlist() and arbitrary_non_reserved_identifier() produced no if/in.

Gates, each run on its own: check:line-endings, typecheck and lint pass. bun test ./tests gives 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):

  • stray-token-detection and string-literal-macro-suppression: an unparenthesized if-condition operand named in would end the condition early. That's possibly the same class of bug, but I haven't reproduced it.
  • arbitrary_command_name(): falls back to arbitrary_identifier(), so the command itself can be if or in.
  • continuation-delimiter-alignment, formatter-indent-correction-alignment, expression-keyword-disambiguation and hover-out-of-scope: they can generate if/in but 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).

@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Next included review available in 5 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available. Your 56 included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Team
  • Run ID: cebe4b2c-551c-488e-8fab-23f06bd870f1
Commits

Reviewing files that changed from the base of the PR and between 3f0bb21 and f700e47.

Files selected for processing: 4
  • tests/property/error-handling-assignment.prop.test.ts
  • tests/property/formatter-source-preservation.prop.test.ts
  • tests/property/generators/primitives.ts
  • tests/property/option-separation.prop.test.ts

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 4e5dcdcb-721f-4cda-9d9d-a33d12faa16d
Commits

Reviewing files that changed from the base of the PR and between 114e945 and 3f0bb21.

Files selected for processing: 4
  • tests/property/error-handling-assignment.prop.test.ts
  • tests/property/formatter-source-preservation.prop.test.ts
  • tests/property/generators/primitives.ts
  • tests/property/option-separation.prop.test.ts

Included review availability: This review used your included allowance. 1 included review remains after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Walkthrough

Property-test generators now avoid reserved identifiers in selected assignment and option-separation cases. The global macro reference generator now produces dollar-sign-prefixed references.

Changes: Property Test Generators

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: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: preventing property tests from generating if or in as variable names and causing flakes.
Docstring Coverage Passed 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. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant