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 inference deduced an incorrect type bytes0. #1707

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

type inference deduced an incorrect type bytes0. #1707

lum7na opened this issue Jan 25, 2025 · 0 comments

Comments

@lum7na
Copy link

lum7na commented Jan 25, 2025

Hi! In the following solidity code, we are assigning a value to a literal array.

contract Test { 
  function test() public {
    [hex""][0] = hex"30";
  }
}

The type of the literal array is inferred as array of bytes0, as evident from the error message output by Solang. I believe bytes0 should not be a valid type, and hex"" should be inferred as bytes1.

Compile: solang compile a.sol --target solana

Output:

error: implicit conversion would truncate from 'bytes1' to 'bytes0'
  ┌─ /home/xxx/a.sol:4:18
  │
4 │     [hex""][0] = hex"30";
  │  
@hyperledger-solang hyperledger-solang deleted a comment Jan 25, 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