Skip to content

Fix BinaryOp '=' overlap with VariableAssignment#268

Open
dhruvv16-hash wants to merge 6 commits intoarxlang:mainfrom
dhruvv16-hash:codex/fix-binaryop-assignment-overlap
Open

Fix BinaryOp '=' overlap with VariableAssignment#268
dhruvv16-hash wants to merge 6 commits intoarxlang:mainfrom
dhruvv16-hash:codex/fix-binaryop-assignment-overlap

Conversation

@dhruvv16-hash
Copy link
Copy Markdown

@dhruvv16-hash dhruvv16-hash commented Mar 28, 2026

Description

Implemented the fix for BinaryOp handling "=" overlapping with VariableAssignment, so assignment is now handled only through VariableAssignment.

Removed assignment handling from BinaryOp in src/irx/builders/llvmliteir.py.
Added a safety guard so BinaryOp("=") now raises:
Assignment '=' should not be handled in BinaryOp. Use VariableAssignment instead.
Kept assignment handling in VariableAssignment, which remains the only valid assignment path.
Added a regression test in tests/test_binary_op.py to verify BinaryOp("=") is rejected.
Added a regression test in tests/test_variable_assignment.py to verify VariableAssignment still updates the variable correctly and print(x) works.

This is a codegen-only change and does not alter parser/frontend behavior.

Fixes: #265

Comments

Please verify that assignment is only handled through VariableAssignment.
Ensure other binary operators like +, -, *, /, and comparisons still behave normally.
The BinaryOp("=") guard is intentional to prevent duplicated codegen paths and preserve the intended language design.

Checklist:

  • The code follows the project style.
  • Regression tests were added.
  • Tests were fully executed locally.

Testing note:
Local automated test execution is still blocked on this machine by environment/dependency setup issues, not by a known code failure.

Before

Before

After

After

@dhruvv16-hash dhruvv16-hash force-pushed the codex/fix-binaryop-assignment-overlap branch from 58890b3 to 26d78c8 Compare March 28, 2026 06:20
@m-akhil-reddy
Copy link
Copy Markdown
Contributor

m-akhil-reddy commented Mar 28, 2026

hi @dhruvv16-hash ,
i am presently working on this issue #265

@dhruvv16-hash
Copy link
Copy Markdown
Author

Hi @m-akhil-reddy,
Thanks for letting me know! I’ve already worked on this and opened a PR (#268) addressing the issue.
It removes '=' handling from BinaryOp and centralizes it in VariableAssignment.
Would be great to get your thoughts on whether this aligns with the intended approach.

@xmnlab
Copy link
Copy Markdown
Contributor

xmnlab commented Apr 1, 2026

@dhruvv16-hash , as a good practice always ask if someone else is already working on an issue. it helps us to keep the community a a nice and friendly space for collaboration.
please don't add the artificts folder.

@xmnlab xmnlab marked this pull request as draft April 1, 2026 16:07
@dhruvv16-hash dhruvv16-hash marked this pull request as ready for review April 1, 2026 18:00
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.

BinaryOp handling "=" overlaps with VariableAssignment

4 participants