Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Runtime Type Checks to Utilize Value-Derived Type Validation #26

Merged
merged 5 commits into from
Aug 15, 2024

Conversation

MidnightDesign
Copy link
Contributor

This refactor introduces a significant change to the runtime type checking mechanism across the codebase. Previously, each type had an associated assertion function responsible for validating its values. The new implementation shifts this responsibility to a more dynamic approach where the type is deduced directly from the value, and then it is validated to determine if it is a subtype of the expected type.

Key changes include:

  • Elimination of the Assert class: The dedicated assertion functions have been removed, as the logic for type validation is now incorporated within the Type class and related expressions.
  • Improved Error Handling: The error messages generated during evaluation now reflect the exact types encountered, providing clearer feedback on type-related issues.

Ditch the assert function and replace it with converting the value to a type and comparing that to the expected type.
@MidnightDesign MidnightDesign marked this pull request as ready for review August 14, 2024 17:10
src/Literal.php Show resolved Hide resolved
@MidnightDesign MidnightDesign merged commit ec579eb into master Aug 15, 2024
35 checks passed
@MidnightDesign MidnightDesign deleted the runtime-type-checks branch August 15, 2024 07:36
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