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

Type checking error in Yul assignment statements #1708

Open
lum7na opened this issue Jan 27, 2025 · 0 comments
Open

Type checking error in Yul assignment statements #1708

lum7na opened this issue Jan 27, 2025 · 0 comments

Comments

@lum7na
Copy link

lum7na commented Jan 27, 2025

An error occurs when assigning a uint8 type (which is actually uint256) to a bytes32 type in Yul assembly, causing the assert for type length to fail.

Compile: solang compile a.sol --target solana

Code:

contract Test {
  function test() external returns(bytes32 result) {
    uint8 st = 127;
    assembly  { result := st }
  }
}

Output:

warning: function can be declared 'pure'
  ┌─ ~/xxx/a.sol:2:3
  │
2 │   function test() external returns(bytes32 result) {
  │   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

thread 'main' panicked at src/emit/expression.rs:2212:13:
assertion `left == right` failed
  left: 1
 right: 32
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Version: solang version v0.3.3-56-g08dbe495

@hyperledger-solang hyperledger-solang deleted a comment Jan 27, 2025
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

No branches or pull requests

1 participant