Migrate error deduplication to node-ID based approach, fixes #71 #108
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 #71
Fixes #108
Summary
Migrates the type checker's error deduplication system from string-based keys to more efficient node-ID based approach using
FxHashSet<(ErrorKind, u32)>.Changes
Added
ErrorKindenum incore/type-checker/src/errors.rsUnknownType,UndefinedFunction,UnknownIdentifier,UndefinedStruct,UndefinedEnumkind()method onTypeCheckErrorOption<ErrorKind>for errors that need deduplicationNonefor other error typesModified
TypeCheckerstruct (core/type-checker/src/type_checker.rs)reported_error_keys: FxHashSet<String>→reported_errors: FxHashSet<(ErrorKind, u32)>push_error_dedupsignaturenode_id: u32parameter(ErrorKind, u32)tuple as deduplication key7 call sites updated to pass node IDs:
3 test expectations updated for new behavior:
test_error_deduplication_same_unknown_type_multiple_uses: 1 → 4 errorstest_error_deduplication_same_undefined_function_multiple_calls: 1 → 2 errorstest_error_deduplication_same_unknown_identifier_multiple_uses: 1 → 3 errorsTesting
Files Modified
cargo build -p inference-type-checker
cargo test -p inference-type-checker
Changes
Added
ErrorKindenum - Categorizes 5 error types needing deduplicationkind()method onTypeCheckError- Returns error categoryModified
TypeCheckerfield:FxHashSet<String>→FxHashSet<(ErrorKind, u32)>push_error_dedupnow acceptsnode_id: u32parameterEOF