Repository navigation
Make the undefinedVariable setting work, checking only commands that take a varlist - #386
Merged
Merged
Conversation
diagnostics.severity.undefinedVariable never reached the analyzer: only tests turned the check on. Turned on as it was, the check read every argument of every command as a variable, giving 514,800 diagnostics over Stata's base ados (as and err in di as err, numbers, strings, macro references). The document store now runs the check, and DiagnosticsProvider keeps dropping its results while the setting is off, its default, so a settings change needs no reparse. The check reads only commands whose arguments are a varlist of existing variables (summarize, tabulate, list, regress, keep, drop, sort, ... with their exact-case abbreviations) and the target of replace, and only plain names that stand alone, so it skips macros, numbers, strings, wildcards, _all, factor-variable and time-series terms, ranges and names joined to a macro. A prefix of a known variable counts, as Stata accepts abbreviations. Base ados: 691 diagnostics with the setting on. confirm variable now matches its subcommand in exact case with every abbreviation down to v (StataMP 18: confirm v x works, confirm Variable x is r(198)), instead of lowercasing it and accepting only variable and var.
su pri was reported when an included file defines price, though the analyzer accepts the abbreviation for a file's own variables. The cross-file checks now try a prefix after the exact name.
Contributor
|
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
|
jbearak
added a commit
that referenced
this pull request
Nov 5, 2026
…riables Since #386, `summarize _b` reports no undefined variable, because `_b` is one of Stata's reserved names, not a variable. The severity-settings property test still drew `_b` as a variable name and failed about one run in six. Co-Authored-By: Claude Opus 5.5 <[email protected]>
jbearak
added a commit
that referenced
this pull request
Nov 5, 2026
…riables (#388) Since #386, `summarize _b` reports no undefined variable, because `_b` is one of Stata's reserved names, not a variable. The severity-settings property test still drew `_b` as a variable name and failed about one run in six. Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Setting
diagnostics.severity.undefinedVariable(insight.tomlor VS Code) did nothing. The check ran only in tests: the language server andsight checknever turned it on. Turned on as it was, it read every argument of every command as a variable. Over Stata 18's 3,780 base ados it gave 514,800 diagnostics:asanderrfromdi as err,local,scalar, 53k numbers, 71k strings and 153k macro references.This PR makes the setting work, with a narrow check:
DiagnosticsProvideralready maps this code's severity from the config and drops it while the setting isoff, the default, so changing the setting needs no reparse. Default output is unchanged.summarize,tabulate,tab1,tab2,list,codebook,inspect,regress,logit,probit,logistic,poisson,correlate,pwcorr,keep,drop,order,sort,destring,tostring,xtsetandtsset. Also the target ofreplace._all, and any name touching another item: factor-variable and time-series terms (i.x,L.x,c.a#c.b), ranges (x1-x3), and names joined to a macro (v`i').su priforprice). This applies to the file's own variables, declared ones, and variables from included files.confirm variablenow matches its subcommand in exact case, with every abbreviation down tov. Before, it lowercased the word and accepted onlyvariableandvar. StataMP 18 runsconfirm v xand rejectsconfirm Variable xwith r(198).The command database has no varlist-position metadata. Checking more commands would mean adding that metadata, which this PR leaves out.
Corpus:
sight checkover Stata 18's 3,780 base adosundefinedVariable = "information"Most of the 691 are variables that
mi,standmergecreate in the dataset (_mi_id,_t,_st,_merge), which the docs say Sight can't see. A few come from text after a top-levelexit, which Stata ignores and Sight still analyzes. That's a separate issue, not fixed here.Proof: StataMP 18 on voyager accepts
confirm variable/var/va/vand rejectsconfirm Variable/VARIABLE(r(198)). 8 of the 11 analyzer/CLI tests fail on main, and the cross-file abbreviation test fails without its fix. All four gates pass. The corpus result is above.Reviewed with sol-loop: 2 rounds with gpt-6.1-sol. Sol verdict: approved
Created with Claude Opus 5.5 in T3 Code (Claude Code harness), reviewed by gpt-6.1-sol in Codex.