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

Yul compilation failed: Top-level expressions are not supposed to return values (this expression returns 1 value). Use pop() or assign them. #307

Closed
agroce opened this issue Mar 15, 2021 · 2 comments · Fixed by #323

Comments

@agroce
Copy link

agroce commented Mar 15, 2021

Compiling this file:

contract C:
 pub def __init__(t:address)->u256:
     return 0
thread 'main' panicked at 'Yul compilation failed: {"errors":[{"component":"general","formattedMessage":"TypeError: Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.\n --> input.yul:1:323:\n  |\n1 |  ... _val { { return_val := 0 leave } } $$__init__(abi_decode_address_mem(params_start_mem, 0)) function contract_create2(data_ptr ...\n  |                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n","message":"Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.","severity":"error","sourceLocation":{"end":377,"file":"input.yul","start":322},"type":"TypeError"}]}', compiler/src/lib.rs:48:27
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9c09c1f7cfcf9de0522bcd1cfda32b552195c464/library/std/src/panicking.rs:493:5
   1: std::panicking::begin_panic_fmt
             at /rustc/9c09c1f7cfcf9de0522bcd1cfda32b552195c464/library/std/src/panicking.rs:435:5
   2: fe_compiler::compile
   3: fe::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Aborted

On latest github master, built with

[profile.dev]
debug = true
panic = "abort"

for fuzzing. Using https://github.com/agroce/afl-compiler-fuzzer

@cburgdorf
Copy link
Collaborator

Nice catch!

@agroce
Copy link
Author

agroce commented Mar 15, 2021

This one took close to 16 days of running the fuzzer to hit (and only detected in one of those runs)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants