Skip to content

Conversation

@MelbourneDeveloper
Copy link
Owner

TLDR

This PR improves the handling of Result types in pattern matching, fixing issues with type inference and string conversion, and adds validation for union type variants.

What Was Added?

  • Added more robust handling for Result types in convertValueToStringByType to handle raw values (arithmetic operations) that are masquerading as Result types.
  • Introduces the isSpecialConstructor function to detect special built-in constructors like Success and Error, and validation for union types.

What Was Changed / Deleted?

  • Modified convertResultToString to use locally defined sprintf and malloc to ensure usage of correct declarations.
  • Enhanced generateSuccessBlock and generateErrorBlock to create new type inference environments for each match arm.
  • Strengthened type inference for pattern variables within Result types in the error block, specifically extracting the error type from the Result generic type.
  • Replaced passing test to failing test and updated validation

How Do The Automated Tests Prove It Works?

  • Updated existing unit tests to validate exhaustiveness for match arms and added test for cases where an unknown variant is used in match.

Summarise Changes To The Spec Here

  • Updated documentation to include Union Types

@MelbourneDeveloper MelbourneDeveloper enabled auto-merge (squash) October 21, 2025 20:47
@MelbourneDeveloper MelbourneDeveloper merged commit 2051ab9 into main Oct 21, 2025
1 check passed
@MelbourneDeveloper MelbourneDeveloper deleted the unknownvarianterror branch October 21, 2025 20:51
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.

2 participants