Skip to content

internal compiler error: no enclosing scope with id XY #3860

Closed
@Blub

Description

@Blub

When a method returns an &self/mut Foo, and the caller doesn't store the returned value somewhere, there's an internal compiler error. See the following code. Note how when storing the result of x.stuff() in a variable makes it work.

struct Foo { x: int }

impl Foo {
    fn stuff(&mut self) -> &self/mut Foo {
        return self;
    }
}

fn main() {
    let mut x = @mut Foo { x: 3 };
    x.stuff(); // error: internal compiler error: no enclosing scope with id 49
    // storing the result removes the error, so replacing the above
    // with the following, works:
    // let _y = x.stuff()

    // also making 'stuff()' not return anything fixes it
    // I guess the "dangling &ptr" cuases issues?
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lifetimesArea: Lifetimes / regionsI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions