feat: Implement TypeInfoKind::Error for type poisoning #103
+166
−67
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.
Description
Closes #72
Changes proposed
What were you told to do?
I was tasked with implementing Error Type Poisoning to prevent cascading errors in the type checker. This involved adding a
TypeInfoKind::Errorvariant similar torustc'sTyKind::Errorand updating the type checker to gracefully handle these error types.What did I do?
Implemented
TypeInfoKind::ErrorErrorvariant to theTypeInfoKindenum incore/type-checker/src/type_info.rs.Displayimplementation to show{unknown}for error types.is_error()helper method toTypeInfo.substituteandhas_unresolved_paramsto handleErrorvariants neutrally.Updated Type Checker Logic
core/type-checker/src/type_checker.rsto useTypeInfoKind::Errorfor type poisoning.infer_expressionforIdentifier,Structinitialization,MemberAccess,TypeMemberAccess, andFunctionCallto returnTypeInfoKind::Errorupon lookup failure instead ofNoneor continuing with invalid types.Statement::Assign,Statement::Return,Statement::If,Statement::Loop, and others to suppress errors if either the expected or found type isError.Expression::ArrayIndexAccess,Expression::PrefixUnary, andExpression::Binaryto propagateErrortypes and suppress secondary errors (e.g., "expected array type" when the array expression itself failed).Benefits
rustc's error handling model.Check List (Check all the applicable boxes)
🚨Please review the contribution guideline for this repository.
Screenshots/Videos