You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(check): static undefined-identifier diagnostic with did-you-mean
The binder now emits a hard RAD20028 Error for every unresolved
identifier instead of leaving the case to the runtime. Same severity
policy as the rest of the static checker - if we can prove it's wrong,
gate it at check time.
What changed:
- binder.go resolveIdentifier no longer returns nil silently on a
miss; emitUndefinedIdentifier appends a BindIssue with the new
diagnostic and a did-you-mean suggestion. The Levenshtein-based
findSimilarNames (new suggestion.go) walks the scope chain + the
builtin set with the same threshold the runtime FindSimilarVars
uses, so the static and runtime suggestion shapes line up.
- FnSignaturesByName is also consulted so the embedded check /
explain scripts that call internal _rad_* builtins still pass
the static check. Internals are excluded from the suggestion
candidate set so users typing a typo don't get nudged toward
runtime-only names.
- Several AST shapes the previous binder didn't visit specifically
needed new cases now that every Identifier sees the checker:
* Shell ('code = $"..."'): targets are declarations, not
uses.
* RadBlock ('rad data:\n fields Name'): field-name idents
come from the data source, not the script's scope - declare
them as locals so downstream uses resolve cleanly.
Cleanup:
- The old addUnknownFunctionHints (RAD40003 hint) becomes a no-op.
The hint was a strictly weaker version of the new error;
surfacing both would double-flag the same problem.
- Binder now sets ArgDecl / CmdArgDecl DeclSpan from NameSpan
rather than the whole node span (was a precursor to commit 16's
find-refs fix, restated here for completeness because the
diagnostic span shifts).
Code actions:
- code_actions.go grows a structured fix for RAD20028 that surfaces
the top did-you-mean candidate as a 'Rename to X' quick fix. The
suggestion string is the carrier today; extractDidYouMeanNames
parses it back into candidate names. A structured field on the
diagnostic would be cleaner; that's a follow-up.
Test migrations:
- core/testing/check_test.go expectations updated to reflect the
new error code at sites that previously fell to RAD40003 hints.
- Several runtime tests (Test_Func_ReadFile_*, Misc_StackTrace*)
used 'print(b)' or 'x = undefined_var' as a way to FORCE a
runtime error. Those now fail statically; rewrote each to use a
runtime-only trigger that exercises the same path the test
cares about.
- Snapshots under core/testing/snapshots/ regenerated. The new
output is mostly tighter - error at check time + suggestions in
one place instead of two layers of runtime diagnostics.
0 commit comments