Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Panic on empty trait impl #833

Closed
mohammadfawaz opened this issue Feb 23, 2022 · 0 comments · Fixed by #838
Closed

Panic on empty trait impl #833

mohammadfawaz opened this issue Feb 23, 2022 · 0 comments · Fixed by #838
Assignees
Labels
bug Something isn't working compiler General compiler. Should eventually become more specific as the issue is triaged team:compiler Compiler Team

Comments

@mohammadfawaz
Copy link
Contributor

mohammadfawaz commented Feb 23, 2022

The script below should not compile but with an error complaining that the function f is not implemented for S.

script;

trait A {
    fn f(self) -> u64;
}
struct S {
    x: u64,
}
impl A for S { 
}
fn main() {
}

Instead, the compiler panics with:

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', sway-core/src/parse_tree/declaration/impl_trait.rs:80:48
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

We do emit the correct error when the trait has multiple functions and only emit a subset of them in the impl block. The above seems to only be a problem when the impl block is empty.

@mohammadfawaz mohammadfawaz added compiler General compiler. Should eventually become more specific as the issue is triaged bug Something isn't working labels Feb 23, 2022
@adlerjohn adlerjohn moved this to Todo in Fuel Network Feb 24, 2022
@mohammadfawaz mohammadfawaz self-assigned this Feb 24, 2022
Repository owner moved this from Todo to Done in Fuel Network Feb 24, 2022
@IGI-111 IGI-111 added the team:compiler Compiler Team label Feb 10, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working compiler General compiler. Should eventually become more specific as the issue is triaged team:compiler Compiler Team
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants