-
Notifications
You must be signed in to change notification settings - Fork 13
Prohibit combined unary operators #111
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
base: main
Are you sure you want to change the base?
Prohibit combined unary operators #111
Conversation
|
@kaankacar Thanks for the contribution. I think that because this check is scope-bounded and not actually a And there is actually a placeholder function for invoking this new crate: https://github.com/Inferara/inference/blob/main/core/inference/src/lib.rs#L330 Also, how about parenthesized expressions such as Since we need to have 3 categories of reporting (info, warning, error), this should also be properly sorted out |
Extract the combined unary operator prohibition from the type-checker into a dedicated `core/semantic-analysis` crate, as this is a semantic check rather than a type check. The pipeline is now: parse -> type check -> semantic check -> codegen - Create `inference-semantic-analysis` crate with 3-level diagnostic reporting (info, warning, error) - Move `is_prefix_unary` / `CombinedUnaryOperators` logic out of the type-checker and into the new semantic analysis pass - Wire up the placeholder `analyze()` in `core/inference` to invoke the new crate - Handle parenthesized expressions like `-(~x)` and `~-(x)` by recursively unwrapping parenthesized nodes - Add dedicated semantic analysis tests; revert type-checker tests to their original expectations Fixes Inferara#82
|
Thanks for the feedback @0xGeorgii! I've pushed an update that addresses all of your points: New
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements semantic analysis to prohibit combined unary operators in the codebase, addressing issue #82. The change introduces a new semantic-analysis module that detects and reports errors for chained or parenthesized unary operator combinations such as --x, !!x, -~x, and -(~x).
Changes:
- Added a new
inference-semantic-analysiscrate with diagnostic types and combined unary operator detection logic - Integrated the semantic analysis pass into the main compilation pipeline after type checking
- Created comprehensive test coverage for valid single unary operators and prohibited combined operators
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| core/semantic-analysis/Cargo.toml | New package definition for the semantic analysis crate |
| core/semantic-analysis/src/lib.rs | Core logic for detecting combined unary operators with pattern matching |
| core/semantic-analysis/src/diagnostics.rs | Diagnostic types and severity levels for semantic analysis results |
| core/inference/src/lib.rs | Updated analyze function to run semantic checks and return errors |
| core/inference/Cargo.toml | Added dependency on the new semantic-analysis crate |
| Cargo.toml | Registered the semantic-analysis workspace member |
| tests/Cargo.toml | Added semantic-analysis as a test dependency |
| tests/src/lib.rs | Added semantic_analysis test module |
| tests/src/semantic_analysis/mod.rs | Module declaration for combined_unary tests |
| tests/src/semantic_analysis/combined_unary.rs | Comprehensive test suite for the combined unary operator checks |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Georgii Plotnikov <accembler@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Georgii Plotnikov <accembler@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Georgii Plotnikov <accembler@gmail.com>
|
@kaankacar Please sync your fork's branch with the latest changes from origin |
…ombined-unary-clean
|
Synced @0xGeorgii |
Prohibit combined unary operators
Fixes #82