Summary
Add a diagnostic warning for variables used in a procedure body that cannot be resolved to any declaration in scope.
Motivation
Currently the extension has no way to catch typos or missing declarations at edit time. The compiler catches these, but early feedback in the editor would improve the development experience.
Scope of work
Clarion variable scope is multi-layered — resolution must check in order:
- Local procedure variables (declared before \CODE)
- Parameters (from the \PROCEDURE()\ signature)
- \LOC:-prefixed parameter aliases
- Module-level variables (declared before the first procedure)
- Global variables (from other \MEMBER\ files)
- Class fields (when inside a method implementation)
- Queue/Group/File fields (accessible after \SET/loop)
- Built-in Clarion identifiers (\RECORDS, \ERRORCODE, \SELF, \PARENT, etc.)
Cross-file resolution is required for globals and class fields, making this expensive and prone to false positives if any layer is incomplete.
Risks / considerations
- High false-positive risk — any missed declaration source produces spurious red squiggles and erodes trust in all diagnostics
- \OMIT/\COMPILE\ conditional blocks mean some declarations may be conditionally absent
- \LIKE, \DIM, embedded group fields, queue fields are all valid declaration sources
- Should be opt-in / off by default via a setting until coverage is solid
- \ScopeAnalyzer\ and \SymbolFinderService\ provide a starting point but do not cover all cases
Suggested approach
Start narrow: single-file procedures only, no cross-file dependencies, flag only obvious unresolved identifiers on the left-hand side of assignments. Expand scope incrementally.
Summary
Add a diagnostic warning for variables used in a procedure body that cannot be resolved to any declaration in scope.
Motivation
Currently the extension has no way to catch typos or missing declarations at edit time. The compiler catches these, but early feedback in the editor would improve the development experience.
Scope of work
Clarion variable scope is multi-layered — resolution must check in order:
Cross-file resolution is required for globals and class fields, making this expensive and prone to false positives if any layer is incomplete.
Risks / considerations
Suggested approach
Start narrow: single-file procedures only, no cross-file dependencies, flag only obvious unresolved identifiers on the left-hand side of assignments. Expand scope incrementally.