Succinct description:
NullReferenceException (NRE) in TypedTree during semantic classification crashes entire document coloring in F# IDE/LSP/VS Code/VS.
Root cause: Mid-edit broken/unresolved symbols → null entity_modul_type / Entity (unlinked placeholders). Derefs like entity_modul_type.Force() / entity.DisplayName → NRE → full pipeline crash.
Fix ready in staged changes: Defensive null-guards + comments in TypedTree.Construct.NewModified*, FreeVars etc. Partial classification survives.
See detailed doc, #20269.
Repro steps
- VS/VS Code: New F# file (
*.fs).
type Foo = // Delete 'type' → unresolved
member x.Bar = ()
- Save → trigger typecheck/classification (edit/save).
- Observe: Entire file loses semantic colors (keywords gray, no blue types/keywords).
Pre-fix: NRE in VS Output (F#) / VS Code DevTools Console (LSP).
Expected behavior
Partial/resilient classification:
- Valid code: Full semantic colors (blue types, green keywords).
- Broken symbol: Isolated error (gray/underline), rest intact.
Actual behavior
NRE propagates:
TypedTree.fs / TypedTreeOps.Remapping.fs → entity_modul_type.Force() → NRE
↑
LanguageService.fs → DocumentCache.fs → classification crash
↓
LSP: semanticTokens/full → empty → no colors for whole file
UX: Plain syntax-only text mid-edit.
Known workarounds
- Fix broken symbol immediately.
- Restart IDE / Reload VS Code window (
Ctrl+Shift+P > "Developer: Reload Window").
- Disable semantic highlighting (VS Code:
fsharp.semanticHighlighting.enabled: false).
Related information
- OS: Windows (tested; likely cross-platform).
- .NET Runtime: net9.0 (F# compiler).
- Editing Tools:
- Visual Studio 17.12+ (F# workload).
- VS Code + F# extension (LSP).
Staged fix files (git diff --staged):
M src/Compiler/TypedTree/TypedTree.fs // Null-guards + comments
M src/Compiler/TypedTree/TypedTree.fsi // Sigs
M src/Compiler/TypedTree/TypedTreeOps.Remapping.fs
M src/Compiler/Utilities/lib.fs
M vsintegration/src/FSharp.Editor/* // LS/cache resilience
Validation: ./build.sh -c Release --testcoreclr clean. IDE resilient.
Commit: Fix NRE in TypedTree: resilient IDE classification (#20269)
Succinct description:
NullReferenceException (NRE) in
TypedTreeduring semantic classification crashes entire document coloring in F# IDE/LSP/VS Code/VS.Root cause: Mid-edit broken/unresolved symbols →
nullentity_modul_type/Entity(unlinked placeholders). Derefs likeentity_modul_type.Force()/entity.DisplayName→ NRE → full pipeline crash.Fix ready in staged changes: Defensive null-guards + comments in
TypedTree.Construct.NewModified*,FreeVarsetc. Partial classification survives.See detailed doc, #20269.
Repro steps
*.fs).Pre-fix: NRE in VS Output (F#) / VS Code DevTools Console (LSP).
Expected behavior
Partial/resilient classification:
Actual behavior
NRE propagates:
UX: Plain syntax-only text mid-edit.
Known workarounds
Ctrl+Shift+P> "Developer: Reload Window").fsharp.semanticHighlighting.enabled: false).Related information
Staged fix files (
git diff --staged):Validation:
./build.sh -c Release --testcoreclrclean. IDE resilient.Commit:
Fix NRE in TypedTree: resilient IDE classification (#20269)