Repository navigation
Read a command's macro writes from one module, so definitions and loop poisoning can't drift - #387
Conversation
…p poisoning can't drift The analyzer kept two parallel lists of the macros a command writes (tempvar, marksample, args, unab, gettoken, file read, local()/global() options, c_local): one registered definitions, the other poisoned loop folds and "mirrored" the first. command_macro_writes now answers both. syntax_locals does the same for `syntax`, which completion had copied and drifted from (it offered `fweight` instead of `weight` and `exp`). A user program's local() option now matches exact-case: in StataMP 18, `myprog, Cache(r)` fails with "option cache() required" and defines nothing. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Every recent "stop reporting X as undefined after " fix had to edit the analyzer twice. One if-chain registered the macros a command writes (tempvar, marksample, args, unab, gettoken, file read,
local()/global()options,c_local). A second chain, documented as "mirroring" the first, told the loop expander which names to poison. The two chains had already drifted on which names count.command_macro_writes(new, insrc/analyzer/command-macro-writes.ts) now answers both: it returns the literal writes, the globalsmacro dropclears, and whether a target name is known only at run time. Adding a command is now one entry in one place, and its tests call that function directly instead of going through the diagnostics pipeline.syntax_localsdoes the same job forsyntax. Completion had kept its own copy of that logic, which offeredfweightfor a weight argument; Stata definesweightandexp.Behaviour changes:
local()option now matches only in lowercase. In StataMP 18,myprog, Cache(r)fails with "option cache() required" and defines nothing.tempvar,unabandargsnames now must be valid identifiers.gettokenandfile readalready had this check, as did loop poisoning.Not changed: Stata also accepts an abbreviated user-program option (
c(r)forCache(string)). Sight didn't recognise abbreviations before this PR and still doesn't.Proof: real-Stata probe on StataMP 18 for the option-case rule; new
tests/unit/command-macro-writes.test.ts; typecheck, lint andbun test ./testspass. The one exception is a pre-existingseverity-settingsproperty flake (_bfrom the generator), which gets its own fix.Reviewed with sol-loop: 1 round with gpt-6.1-sol. Sol verdict: approved
Created with Claude Opus 5.5 in T3 Code.
Summary by CodeRabbit
anythingand weight arguments.