Repository navigation
Parse a prefixed frame block named by a macro as one frame block, not a command named frame - #406
Conversation
`capture frame `f' {` and `cap frame $g {` fell back to a plain command
named `frame`, so the program or file after it was misread, and
`capture frame `f': cmd` lost `cmd`. The unprefixed path already
accepted a macro name; the prefixed block and one-line prefix paths
now use the same check. Stata 18 runs every form.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
A
frameblock with prefixes is already oneframestatement on 0.17.3:capture noisily frame F { … }parses withprefixes: ["capture", "noisily"],frame: "F", and abody. A prefixed block whose frame name is a macro did not:program define p capture noisily frame `0' { replace x = 1 } endHere
frameand`0'became a plain command namedframe, the{was reported asOPEN_BRACE_ALONE, and the block's body and everything after it were misread. In this example the program swallowed the rest of the file, and Sight reportedMissing "end". The one-line form had the same gap:capture noisily frame `f': replace x = 1came out as a command namedframe, soreplacewas lost. This affects tools that walk prefixed frame blocks throughsight parse --json, as well as the editor's diagnostics.The unprefixed path already accepted a macro as the frame name. The prefixed-block check and the
frame name:prefix path now use the same check: a word, or a local or global macro reference.Checked in StataMP 18 (the fixture
frame-blocks.do, run as is):frame F {,capture noisily frame F {,quietly frame F {,noisily quietly capture frame F {,capture noisily frame `f' {, andquietly capture frame $g {all run their bodies in frameF;frame F: cmdandcapture noisily frame `f': cmdrun one command, with no block;frame F {inside aforeachloop runs once per iteration.For a missing
}, Stata reportsprogram error: matching close brace not found, both at the end of a file and when a program'sendcomes first. Sight reportsMissing closing brace for frame blockat the end of a file. As for every other block type, it ends the program atendand adds no error there (the convention from #369 and #393).The JSON shape gains no fields.
docs/cli.mdnow says that aframestatement hasprefixes, thatframeis the name as written (possibly a macro), and how a missing}is reported.Proof: new parser tests and two
sight parse --jsongolden fixtures (frame-blocks.do,frame-unclosed.do). 7 of these tests fail without the fix. Every fixture form also runs in StataMP 18. Line endings, typecheck,bun test ./tests(9,783 pass, 0 fail), and lint pass.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).
Summary by CodeRabbit
framecommand prefixes that use macro-based frame names, including abbreviated forms.enddoes not close an open frame block.