Skip to content

Stop reporting a local as undefined after an abbreviated program option, such as myprog, c(r) for Cache(string) - #390

Merged
jbearak merged 1 commit into
mainfrom
fix/program-option-abbreviations
Nov 5, 2026
Merged

jbearak merged 1 commit into
mainfrom
fix/program-option-abbreviations

Conversation

@jbearak

@jbearak jbearak commented Nov 5, 2026

Copy link
Copy Markdown
Owner

A user program whose syntax has Cache(string) and that runs c_local `cache' defines r in the caller for myprog, c(r), because Stata takes the leading capitals as the minimum abbreviation. Sight matched only the full option name. It then reported `r' as an undefined macro.

User-program options now match the way StataMP 18 does:

  • down to the leading capitals (LOCal accepts loc, loca, local);
  • in full when the name has no capitals or is all capitals (cache, CACHE);
  • only in lowercase (LOC(r) is rejected).

After #387 this is one change in command_macro_writes. It reuses the case-sensitive matches_option that built-ins already use.

Proof: probed every rule above on StataMP 18. The new tests in tests/unit/command-macro-writes.test.ts fail without the fix. An end-to-end test checks that the diagnostic is gone. Typecheck, lint, and bun test ./tests pass (9619 tests).

Not changed: hover's "Minimum Abbreviation" comes from the parser's compute_min_abbreviation, which doesn't follow this rule either (it shows c for an all-lowercase cache).

Reviewed with sol-loop: 1 round with gpt-6.1-sol. Sol verdict: approved

Created with Claude Opus 5.5 in T3 Code.

@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

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 41 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available. Your 65 included PR review attempts over the past 7 days set your current allowance at 2 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: df4ea6bc-0b40-4773-8715-87670c09be10
Commits

Reviewing files that changed from the base of the PR and between f5a0898 and 0b0b5b6.

Files selected for processing: 4

  • docs/cross-file.md
  • src/analyzer/command-macro-writes.ts
  • tests/unit/analyzer.test.ts
  • tests/unit/command-macro-writes.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

…on, such as myprog, c(r) for Cache(string)

A user program whose syntax has Cache(string) and that c_locals
`cache' defines r for `myprog, c(r)`, since Stata takes the leading
capitals as the minimum abbreviation. Sight matched only the full
name, so it reported `r' as undefined. Program options now match as
StataMP 18 does: down to the leading capitals, in full when there are
none or all are capitals, and only in lowercase.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jbearak
jbearak force-pushed the fix/program-option-abbreviations branch from 64bd428 to 0b0b5b6 Compare November 5, 2026 21:02
@jbearak
jbearak merged commit 959f4b0 into main Nov 5, 2026
16 checks passed
@jbearak
jbearak deleted the fix/program-option-abbreviations branch November 5, 2026 21:06
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