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

closes #19 with basic type checking #21

Merged
merged 8 commits into from
Jan 11, 2025
Merged

closes #19 with basic type checking #21

merged 8 commits into from
Jan 11, 2025

Conversation

eckertliam
Copy link
Owner

Implemented a very basic naive type checker loosely based on algorithm W

- Added constant folding logic to evaluate array sizes at compile time.
- Updated error handling for negative and invalid sizes.
- Modified test cases to reflect changes in expression handling.
- Introduced a new `Array` variant in the `Expression` enum to represent array expressions.
- Implemented a `new_array` method for creating array expressions.
- Updated the type inference logic to handle array expressions in the type pass.
- Enhanced the `Type` enum with a display implementation for better type representation.
- Added a structure for managing type environments, allowing for nested scopes and type resolution.

This commit lays the groundwork for future array expression handling in the parser and type system.
- Simplified the `Array` variant in the `Expression` enum to use a tuple struct for better clarity.
- Enhanced the `TokenKind` enum with a `Display` implementation for improved string representation of tokens.
- Updated type inference logic to accommodate the new `Array` structure.
- Added comprehensive tests for type inference, including support for arrays and various expression types.

These changes streamline the AST and type inference process, laying the foundation for more robust expression handling in the type system.
- Reformatted struct and function declarations in `ast.rs` for better readability.
- Updated `FnSig` type alias in `types.rs` to simplify function signature handling.
- Modified type inference functions in `type_pass.rs` to accept mutable references to `TypeEnv`, enhancing type environment management.
- Added new type checking functions for statements, improving type validation during the inference process.
- Enhanced tests to ensure proper type inference and error handling across various expression and statement types.

These changes streamline the AST structure and type inference logic, paving the way for more robust type checking in the system.
@eckertliam eckertliam linked an issue Jan 11, 2025 that may be closed by this pull request
@eckertliam eckertliam merged commit 374a179 into main Jan 11, 2025
1 check passed
@eckertliam eckertliam deleted the 19-ast-tc branch January 11, 2025 01:55
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.

Implement type checking over the AST
1 participant