Repository navigation
fix(analyzer): source checkers read analyzeExpression() options - #149
Merged
Merged
Conversation
The ESLint rule, fhirpath-check source pass, and playground read the env/envTypes/vars/varTypes and variables options of analyzeExpression() and analyzeExpressionDetailed() calls, so names declared there no longer report unknown-variable. Fixes #148.
…erit no engine varTypes
- CallSitePolicy.options { arg, type: 'EvaluateOptions' | 'AnalyzeOptions' }
replaces optionsArg, optionsExpressions, and optionsVariables.
- An AnalyzeOptions site never inherits the engine's default varTypes, so the
CLI no longer types a 'variables' name from an engine declaration.
- CHANGELOG Unreleased entries.
…engine calls Settled with the user: handle inline functions in this PR. Names in a literal functions option are declared with any arity and unknown type, and win over defaults. Options that may hold unnamed functions (a functions variable, a spread, a non-literal options object) silence unknown-function.
…tions A call whose functions option the source cannot fully name may replace any engine function, so analyzeSite analyzes it with only the call's own function names instead of keeping stale default arities and result types.
fjsj
deleted the
fjsj/source-checkers-ignore-analyzeexpression-options
branch
November 6, 2026 22:35
Merged
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.
Fixes #148.
The ESLint rule, the
fhirpath-checksource pass, and the playground read the options ofanalyzeExpression()andanalyzeExpressionDetailed()calls, as they read an engine call's options. They also read thefunctionsoption of analyzer and engine calls.Changes
CallSitePolicy.options(src/analyzer/expression-policy.ts) gives the options argument and its type,EvaluateOptionsorAnalyzeOptions. OneANALYZER_CALLpolicy serves both analyzer calls.AnalyzeOptions,optionScopes()also readsvariables. Its names are declared untyped and win over anenv/varstype of the same name, as in the analyzer. A spread, a computed key, or a non-literal object leaves the names open, so an unresolved%nameis not an error.varsexpressions are not checked, since the analyzer does not report their diagnostics. An analyzer call does not inherit the engines' defaultvarTypesinfhirpath-check, since it never sees them at runtime.optionScopes()reads the names of a call'sfunctionsoption. A named function is declared with any arity and replaces an engine function of the same name, as at runtime. When the source cannot read the option (a variable or a spread), the site is checked with the call's own names only and an unknown function is not reported.analyzeSitechecks variables at a declared-root site when the site read its call's own options. SoanalyzeExpression('%typo', { inputType: 'Patient' })reportsunknown-variable, which is what the call returns. Afhirpath(expr, 'Patient')site still does not, because its expression runs elsewhere.docs/static-checking.mdandCHANGELOG.mddescribe the new behavior.Tests
src/analyzer/expression-policy.test.ts):variables,env,vars,varTypes,varsbodies, open options,variablesover a typedenv, thefunctionsoption, and openfunctions.src/cli/fhirpath-check.test.ts, through the CLI: an analyzer call does not get the engine's defaultvarTypes, and a call that may replace the engine's functions drops their declarations.Each new test fails without its fix.
pnpm typecheckpnpm lintpnpm testpnpm check:fhirpathpnpm coveragepnpm buildpnpm check:package🤖 Generated with Claude Code