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

mapping storageRef cannot be converted to mapping storage pointer #1689

Open
haoyang9804 opened this issue Jan 9, 2025 · 0 comments
Open

Comments

@haoyang9804
Copy link

haoyang9804 commented Jan 9, 2025

Describe the bug

When I define a function that returns a mapping storage pointer and returns a state mapping variable (which is actually storage reference), Solang sometimes allows the behavior but sometimes forbids it.

Found by Erwin

To Reproduce
Use solang compile --target solana <program_path> to compile the two source code given below, you can find that the first fails the compilation while the second passes.
Expected behavior
The two source code should have the trigger the same compilation results. And I guess, they should both pass the compilation.

Screenshots
The compilation result of the first source code:
Image
That of the second one.
Image

Hyperledger Solang version
solang version v0.3.3

Include the complete solidity source code
The source code that fails the compilation

contract contract0 {
  mapping(int16 => int16) internal mapping14;
  mapping(int16 => int16) internal mapping17;

  function func8() internal returns (mapping(int16 => int16) storage mapping9, int16 var12) {
    int16 var20 = (int16(-32200));
    return ((true) ? mapping17 : mapping14, var20);
  }
}

The source that passes the compilation

contract contract0 {
  mapping(int16 => int16) internal mapping14;
  mapping(int16 => int16) internal mapping17;

  function func8() internal returns (mapping(int16 => int16) storage mapping9) {
    return ((true) ? mapping17 : mapping14);
  }
}
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