Skip to content

Forbid passing aggregates and u256 and b256 to asm blocks without explicitly passing an address #6993

Open
@ironcev

Description

@ironcev

When writing ASM blocks, developers are repeatedly running into a trap caused by the fact that aggregates and b256 and u256 values can be passed, apparently "by value" to ASM blocks, whereas what is actually passed is their memory address sonverted to u64.

E.g., in this example, it looks like we are taking an 0th root of 0x64u256. But what is actually passed to the ASM block is the address of the 0x64u256 instance in memory converted to u64. mroodoes not operate onu256but will accept theu64` value.

asm(r1: 0x64u256, r2: 0x00u256, r3) {
    mroo r3 r1 r2;
    r3: u256
};

In the past, we got several questions on apparently correct code not working, and the reason was always the deceiving passing of values, where actually addresses are passed.

The proposal is to forbid passing aggregates and u256 and b256 to ASM blocks directly, but to force developers to take their addresses explicitly and pass them.

Rust follows the same approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breakingMay cause existing user code to break. Requires a minor or major release.compilerGeneral compiler. Should eventually become more specific as the issue is triagedcompiler: frontendEverything to do with type checking, control flow analysis, and everything between parsing and IRgenteam:compilerCompiler Team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions