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

unit type is not abi encodable at crates/analyzer/src/namespace/types.rs:598:27 #480

Closed
agroce opened this issue Jul 9, 2021 · 2 comments
Labels
flag: beta-required Required for first beta release

Comments

@agroce
Copy link

agroce commented Jul 9, 2021

Compiling this file:

contract o:
 d:(())
thread 'main' panicked at 'unit type is not abi encodable', crates/analyzer/src/namespace/types.rs:598:27
stack backtrace:
   0:     0x5649ca04f7d0 - std::backtrace_rs::backtrace::libunwind::trace::h63b7a90188ab5fb3
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x5649ca04f7d0 - std::backtrace_rs::backtrace::trace_unsynchronized::h80aefbf9b851eca7
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x5649ca04f7d0 - std::sys_common::backtrace::_print_fmt::hbef05ae4237a4d72
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x5649ca04f7d0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h28abce2fdb9884c2
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x5649ca0689bf - core::fmt::write::h3b84512577ca38a8
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/core/src/fmt/mod.rs:1092:17
   5:     0x5649ca04d232 - std::io::Write::write_fmt::h465f8feea02e2aa1
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/io/mod.rs:1572:15
   6:     0x5649ca051965 - std::sys_common::backtrace::_print::h525280ee0d29bdde
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x5649ca051965 - std::sys_common::backtrace::print::h1f0f5b9f3ef8fb78
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x5649ca051965 - std::panicking::default_hook::{{closure}}::ha5838f6faa4a5a8f
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:208:50
   9:     0x5649ca051413 - std::panicking::default_hook::hfb9fe98acb0dcb3b
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:225:9
  10:     0x5649c9f9c326 - fe_common::panic::DEFAULT_PANIC_HOOK::{{closure}}::{{closure}}::hc9c371f2106ced58

You've hit an internal compiler error. This is a bug in the Fe compiler.
Fe is still under heavy development, and isn't yet ready for production use.

If you would, please report this bug at the following URL:
  https://github.com/ethereum/fe/issues/new
Aborted

Using

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

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

@cburgdorf
Copy link
Collaborator

I looked into this yesterday but I'm not exactly sure how to fix it. The reason for this error is because unit types aren't currently ABI encodable which causes to blow up here

Base::Unit => panic!("unit type is not abi encodable"),

That's because of the struct that contains fields of type ()

let structs_batch = attributes
.structs
.clone()
.into_iter()
.map(|struct_| vec![FixedSize::Struct(struct_)])
.collect::<Vec<Vec<_>>>();

So the following call then starts the trouble

functions::abi::batch_encode(batch)

I'm wondering how we want to address this. We could prevent fields of type () in structs but I'm not sure if that's the right call since e.g. in Rust it is perfectly valid to have something like let x = ((),()).

The abi-spec explicitly mentions that zero sized tuples are valid so I'm thinking we should just encode the unit type as an empty tuple. Thoughts @g-r-a-n-t ?

@cburgdorf cburgdorf added the flag: beta-required Required for first beta release label Aug 12, 2021
@Y-Nak
Copy link
Member

Y-Nak commented Jul 29, 2022

fixed in #676

@Y-Nak Y-Nak closed this as completed Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flag: beta-required Required for first beta release
Projects
None yet
Development

No branches or pull requests

3 participants