feat(slang): complete operator emission#552
Open
hedgar2017 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR completes several operator-emission behaviors in the Slang frontend by refining operand coercion rules (notably for comparisons, shifts, exponentiation, and fixed-bytes bitwise ops) and extending the MLIR layer to properly detect and reconcile fixed-bytes types during coercion and comparisons.
Changes:
- Introduces
FunctionScope::coerced()and applies it broadly to simplify/standardize “emit then coerce” call sites. - Updates shift/exponentiation and compound-assignment lowering to keep the RHS operand at its original type (instead of coercing both operands to the result type).
- Extends MLIR type/value utilities with fixed-bytes inspection and comparison reconciliation logic, and adds/updates lit tests covering fixed-bytes bitwise/shift and mixed-width integer comparisons.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| solx-slang/src/contract/function/statement/variable_declaration.rs | Uses the new coerced() helper for initializer coercion. |
| solx-slang/src/contract/function/expression/unary.rs | Refactors unary operator lowering to use coerced() consistently. |
| solx-slang/src/contract/function/expression/mod.rs | Adds FunctionScope::coerced() and refactors coerced_operands() to use it. |
| solx-slang/src/contract/function/expression/call/mod.rs | Switches call argument coercions to coerced() for consistency. |
| solx-slang/src/contract/function/expression/call/arguments.rs | Uses coerced() for parameter/argument coercion. |
| solx-slang/src/contract/function/expression/bitwise.rs | Adjusts shift lowering so shift amounts keep their own type. |
| solx-slang/src/contract/function/expression/assignment.rs | Keeps RHS type for shift compound assignments; coerces RHS for other compound ops. |
| solx-slang/src/contract/function/expression/array.rs | Uses coerced() for array literal element coercion. |
| solx-slang/src/contract/function/expression/arithmetic.rs | Adjusts exponentiation lowering so exponent keeps its own type. |
| solx-mlir/tests/lit/fixed_bytes_shift.sol | Adds lit coverage for fixed-bytes shift with typed shift amounts. |
| solx-mlir/tests/lit/fixed_bytes_bitwise.sol | Adds lit coverage for fixed-bytes bitwise ops (~, ^). |
| solx-mlir/tests/lit/comparison.sol | Expands lit coverage for mixed-width integer comparisons. |
| solx-mlir/tests/lit/bitwise.sol | Expands lit coverage for shifts with “wide” RHS shift amounts and signed shift-right. |
| solx-mlir/tests/lit/arithmetic.sol | Updates arithmetic lit coverage to reflect revised operator emission (notably exp/neg cases). |
| solx-mlir/src/ir/value.rs | Extends coercion to route fixed-bytes coercions through bytes_cast; updates comparison reconciliation logic. |
| solx-mlir/src/ir/type/mod.rs | Adds fixed-bytes type predicates/accessors used by coercion and comparisons. |
| solx-mlir/src/ffi.rs | Exposes new fixed-bytes inspection functions via Rust FFI. |
| solx-mlir/sol_attr_stubs.cpp | Implements the fixed-bytes type predicate and size accessor for the Rust FFI. |
hedgar2017
marked this pull request as ready for review
July 15, 2026 20:43
hedgar2017
force-pushed
the
az-slang-operator-completion
branch
3 times, most recently
from
July 16, 2026 18:36
bd8421f to
4bb4143
Compare
hedgar2017
force-pushed
the
az-slang-scope-poc
branch
from
July 16, 2026 21:51
65746b1 to
ef62b4a
Compare
hedgar2017
force-pushed
the
az-slang-operator-completion
branch
from
July 16, 2026 22:16
4bb4143 to
273c366
Compare
hedgar2017
force-pushed
the
az-slang-scope-poc
branch
from
July 17, 2026 14:56
21973e4 to
75139ef
Compare
hedgar2017
force-pushed
the
az-slang-operator-completion
branch
from
July 17, 2026 15:24
273c366 to
994ba87
Compare
hedgar2017
force-pushed
the
az-slang-operator-completion
branch
from
July 17, 2026 17:30
994ba87 to
83eed32
Compare
hedgar2017
force-pushed
the
az-slang-operator-completion
branch
4 times, most recently
from
July 19, 2026 03:43
97bd564 to
e6bb2b8
Compare
Comparison coerces its operands to the common type the slang binder reconciles them to, read back through the binder rather than recomputed here. The right operand of a shift or exponentiation keeps its own type rather than a cast to the result type, which also removes a spurious cast on signed right shifts. Bitwise, shift, and negation operators apply directly to fixed-bytes values, whose coercion left-aligns through a dedicated bytes cast, backed by fixed-bytes type queries added to the dialect C API shim. LIT: extends the arithmetic, bitwise, and comparison oracles and adds fixed-bytes bitwise and shift fixtures.
hedgar2017
force-pushed
the
az-slang-operator-completion
branch
from
July 19, 2026 12:57
e6bb2b8 to
ff267ad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Completes operator emission on the Slang frontend: