solang icon indicating copy to clipboard operation
solang copied to clipboard

[ICE]: bytes4 causes a compilation error.

Open Subway2023 opened this issue 8 months ago • 1 comments

Version: v0.3.3: v0.3.3-70-g32a45ea1 Description: Error handling may need optimization.

contract ByteCast {
    function fixedToDynamic(bytes32 _fixed) public pure returns (bytes memory) {
        return bytes4(_fixed);
    }
}
solang compile --target solana test.sol

thread 'main' panicked at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/inkwell-0.4.0/src/values/enums.rs:302:13:
Found IntValue(IntValue { int_value: Value { name: "", address: 0x64e424bbfe50, is_const: false, is_null: false, is_undef: false, llvm_value: "  %4 = trunc i256 %3 to i32", llvm_type: "i32" } }) but expected PointerValue variant

Subway2023 avatar Mar 10 '25 04:03 Subway2023

Converting bytes to integer also causes error, shown in remainder := mod(sub(b, a), 0x20)

contract C {
    function diff() public pure returns (uint256 remainder) {
        bytes memory a = hex"";
        bytes memory b = hex"";
        assembly {
            remainder := mod(sub(b, a), 0x20)
        }
   
thread 'main' panicked at 'Found StructValue(StructValue { struct_value: Value { name: "", address: 0x62505d7c4f50, is_const: true, is_null: false, is_undef: false, llvm_value: "{ ptr, i64 } { ptr @const_string, i64 0 }", llvm_type: "{ ptr, i64 }" } }) but expected PointerValue variant', /github/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/inkwell-0.2.0/src/values/enums.rs:302:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Subway2023 avatar Apr 16 '25 04:04 Subway2023