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

failed to analyze lowered AST: AnalyzerError([Diagnostic { severity: Error, code: None, message: "No field... at compiler/src/lib.rs:55:59 #470

Closed
agroce opened this issue Jun 28, 2021 · 4 comments

Comments

@agroce
Copy link

agroce commented Jun 28, 2021

Compiling this file:

contract o:
 def m(my_tuple:(u256,bool,address))->u256:
  return my_tuple.item00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
thread 'main' panicked at 'failed to analyze lowered AST: AnalyzerError([Diagnostic { severity: Error, code: None, message: "No field `item00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000` exists on struct `tuple_u256_bool_address_`", labels: [Label { style: Primary, file_id: SourceFileId(226182870253612458078089501400146892043), range: 74..449, message: "undefined field" }], notes: [] }])', compiler/src/lib.rs:55:59
stack backtrace:
   0:     0x5571da8c29b0 - std::backtrace_rs::backtrace::libunwind::trace::h63b7a90188ab5fb3
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x5571da8c29b0 - std::backtrace_rs::backtrace::trace_unsynchronized::h80aefbf9b851eca7
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x5571da8c29b0 - std::sys_common::backtrace::_print_fmt::hbef05ae4237a4d72
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x5571da8c29b0 - <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:     0x5571da8dbb9f - core::fmt::write::h3b84512577ca38a8
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/core/src/fmt/mod.rs:1092:17
   5:     0x5571da8c0412 - std::io::Write::write_fmt::h465f8feea02e2aa1
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/io/mod.rs:1572:15
   6:     0x5571da8c4b45 - std::sys_common::backtrace::_print::h525280ee0d29bdde
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x5571da8c4b45 - std::sys_common::backtrace::print::h1f0f5b9f3ef8fb78
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x5571da8c4b45 - std::panicking::default_hook::{{closure}}::ha5838f6faa4a5a8f
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:208:50
   9:     0x5571da8c45f3 - std::panicking::default_hook::hfb9fe98acb0dcb3b
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:225:9
  10:     0x5571d9f65071 - fe_compiler::errors::DEFAULT_PANIC_HOOK::{{closure}}::{{closure}}::hee6f55e1ea35c885

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

@andy-ow
Copy link
Contributor

andy-ow commented Aug 8, 2021

Should a field like my_tuple.item00 be interpreted as item0 ? or rather, should the compiler give an error message like:
"Tuple values are accessed via itemN properties such as item0 or item1"
?

@mjobuda
Copy link
Contributor

mjobuda commented Aug 8, 2021

As far as i understand:

  1. the panics are removed one by one. Preferably in the beta there should when possible an error message fein the compiler describing what's going on.

I'm also pretty sure that the answer to your question hasn't been settled, otherwise the bug wouldn't be here.
Because obviously when you parse the string "0" for and int (without knowing here the implementation details) it can be interpreted as the same as parsing from "00".
I guess the behavior has yet to be specified for this.
In my opinion item0 shouldn't be the same as item00000. That's just confusing and unnecessary obfuscating source code, so I'm in favour of your suggestion.

@g-r-a-n-t
Copy link
Member

g-r-a-n-t commented Aug 10, 2021

I agree, leading zeros should not be valid.

This is where tuple attributes are validated:

/// Pull the item index from the attribute string (e.g. "item4" -> "4").
fn tuple_item_index(item: &str) -> Option<usize> {
if item.len() < 5 || &item[..4] != "item" {
None
} else {
item[4..].parse::<usize>().ok()
}
}

Basically we just need to check for a single leading zero, so something as simple as this should work:

if item.len() > 5 && item[4] == "0" then the attribute is invalid

sbillig added a commit that referenced this issue Aug 11, 2021
@sbillig
Copy link
Collaborator

sbillig commented Dec 13, 2021

Fixed in #510

@sbillig sbillig closed this as completed Dec 13, 2021
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

5 participants