Skip to content

Refactor: implement "TypeCheckVisitor" for type-checking - #7

Merged
writemorecode merged 2 commits into
mainfrom
refactor/type_checking
Feb 9, 2026
Merged

Refactor: implement "TypeCheckVisitor" for type-checking#7
writemorecode merged 2 commits into
mainfrom
refactor/type_checking

Conversation

@writemorecode

Copy link
Copy Markdown
Owner

This PR replaces the old checkTypes API for type-checking with a new TypeCheckVisitor type. This is similar to a previous PR, which refactored the symbol table construction #6 .

Bugs fixed:
- Control statement type checking only validated the condition type and ignored nested statement failures.
- MethodWithoutParametersNode reported return-type mismatches but still returned success.
- ClassAllocationNode accepted undeclared class names as valid types.

How this commit fixes them:
- ControlStatementNode::checkTypes now checks both condition and statement branch results, propagating failure when either side is invalid.
- MethodWithoutParametersNode::checkTypes now returns failure after emitting a return-type mismatch diagnostic.
- ClassAllocationNode::checkTypes now verifies the allocated class exists in the symbol table and reports an error otherwise.

Tests added:
- ControlStatementPropagatesStatementTypeFailure
- MethodWithoutParametersReturnMismatchFailsTypeCheck
- ClassAllocationRequiresDeclaredClassType

Validation:
- ctest --test-dir build --output-on-failure (35/35 passing).
@writemorecode
writemorecode merged commit 18cb96a into main Feb 9, 2026
1 check passed
@writemorecode
writemorecode deleted the refactor/type_checking branch February 11, 2026 09:58
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.

1 participant