Skip to content

"LLVM ERROR: Broken function found" with UFCS and static methods #18539

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

Closed
ghost opened this issue Nov 2, 2014 · 3 comments · Fixed by #18545
Closed

"LLVM ERROR: Broken function found" with UFCS and static methods #18539

ghost opened this issue Nov 2, 2014 · 3 comments · Fixed by #18545
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@ghost
Copy link

ghost commented Nov 2, 2014

struct Foo;

impl Foo {
    fn from_uint(x: uint) -> Foo {
        Foo
    }
}

fn main() {
    range(0u, 10).map(Foo::from_uint);
}

Out:

Function return type does not match operand type of return inst!
  ret void
 %"struct.Foo<[]>" = type {}LLVM ERROR: Broken function found, compilation aborted!
@ghost ghost added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Nov 2, 2014
@bkoropoff
Copy link
Contributor

It seems to occur even without UFCS:

struct Foo;

fn uint_to_foo(x: uint) -> Foo {
    Foo
}

fn main() {
    range(0u, 10).map(uint_to_foo);
}

@luqmana
Copy link
Member

luqmana commented Nov 2, 2014

The problem seems to be with zero-sized types. Since this works fine:

struct Foo(uint);

fn uint_to_foo(x: uint) -> Foo {
    Foo(x)
}

fn main() {
    range(0u, 10).map(uint_to_foo);
}

@luqmana
Copy link
Member

luqmana commented Nov 2, 2014

Ok, yea the problem is when we coerce a bare fn that returns a zero sized type to a closure. I'll put up a PR once I've tested this fix a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants