Skip to content

Fix trait conformance crash when workspace has partial signature diagnostics - #340

Merged
pouya-eghbali merged 1 commit into
developfrom
fix/trait-conformance-partial-signatures
Nov 25, 2026
Merged

pouya-eghbali merged 1 commit into
developfrom
fix/trait-conformance-partial-signatures

Conversation

@pouya-eghbali

Copy link
Copy Markdown
Member

Summary

Fixes an uncaught std::out_of_range (unordered_map::at: key not found) abort in kalandra, kalandra-check, and kalandra-lsp when any function signature in a single-file or multi-module workspace emits a diagnostic while another function exercises trait conformances.

Root Cause

  • Checker::run() previously left genericRegistryReady_ = false whenever registerSignatures() produced any diagnostic (because validateTraitImplementations() was skipped when !diagnostics_.empty()).
  • Body and editorOnly analysis still proceeded, causing requireConformance() to return declaration-only conformances with an empty conformance->methods map and abort at conformance->methods.at(...) across trait method calls, trait function values, Display (format), Equal (==/!=), and custom arithmetic operators.

Changes

  • Mark genericRegistryReady_ = true unconditionally after registerSignatures() in Semantics.cpp so valid trait conformances upgrade to full method bindings during body/LSP checking even when an unrelated signature fails.
  • Guard all five conformance->methods lookups (TraitChecking.h, GenericProjections.h, ArithmeticChecking.h, and Display/Equal in Semantics.cpp) with .find(...) instead of .at(...).
  • Ensure cached specializeFunction and specializeRecord lookups return std::nullopt when an earlier specialization failed signature or field population.
  • Add single-file, multi-module, and LSP editor/protocol regression tests in GenericsTests.cpp, RecoveryTests.cpp, and RecoveryProtocolTests.py.

Verification

  • ctest --test-dir build/native --output-on-failure -j8 -R '^(frontend-generics-(debug|sanitized)|native-lsp-recovery(-protocol)?-(debug|sanitized)|native-lsp-(debug|sanitized))$' (8/8 passed)

@pouya-eghbali
pouya-eghbali merged commit 124cc9d into develop Nov 25, 2026
18 checks passed
@pouya-eghbali
pouya-eghbali deleted the fix/trait-conformance-partial-signatures branch November 25, 2026 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant