Skip to content

Conversation

@Arowolokehinde
Copy link

Summary

Migrates error deduplication from string-based keys to node-ID-based tuples (ErrorKind, u32) for improved performance and memory efficiency.

Fixes #71
Fixes #108

AI Assistance Disclosure

This implementation was developed with the assistance of Claude (A). All code was manually reviewed and tested before submission.

Changes

Added

  • ErrorKind enum in core/type-checker/src/errors.rs

    • Categorizes the 5 error types that require deduplication
    • UnknownType, UndefinedFunction, UnknownIdentifier, UndefinedStruct, UndefinedEnum
  • kind() method on TypeCheckError

    • Returns Option<ErrorKind> for errors that need deduplication
    • Returns None for other error types

Modified

  • TypeChecker struct (core/type-checker/src/type_checker.rs)

    • Changed field: reported_error_keys: FxHashSet<String>reported_errors: FxHashSet<(ErrorKind, u32)>
  • push_error_dedup signature

    • Now accepts node_id: u32 parameter
    • Uses (ErrorKind, u32) tuple as deduplication key
  • 7 call sites updated to pass node IDs:

    • Generic type base validation (line 443)
    • Generic type parameter validation (line 454)
    • Custom type validation (line 468)
    • Enum definition validation (line 963)
    • Function call validation (line 1203)
    • Struct expression validation (line 1305)
    • Identifier validation (line 1525)
  • 3 test expectations updated for new behavior:

    • test_error_deduplication_same_unknown_type_multiple_uses: 1 → 4 errors
    • test_error_deduplication_same_undefined_function_multiple_calls: 1 → 2 errors
    • test_error_deduplication_same_unknown_identifier_multiple_uses: 1 → 3 errors

Files Modified

  • core/type-checker/src/errors.rs - Added ErrorKind enum and kind() method
  • core/type-checker/src/type_checker.rs - Updated deduplication logic and call sites
  • tests/src/type_checker/error_recovery.rs - Updated test expectations
  • implemenration.md - Added implementation documentation

cargo build -p inference-type-checker
cargo test -p inference-type-checker


Testing

  • ✅ All type-checker unit tests pass (71 tests)
  • ✅ Build succeeds: cargo build -p inference-type-checker
  • ✅ Test expectations updated to reflect new behavior
  • ✅ No breaking changes to public API (all changes are internal)

@Arowolokehinde
Copy link
Author

@0xGeorgii you can review the pr now

@Arowolokehinde
Copy link
Author

@0xGeorgii can you kindly review the pr now

@Arowolokehinde
Copy link
Author

@0xGeorgii Can you kindly review?

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.

Node-ID-Based Error Deduplication

1 participant