Skip to content

Must check mutability when instantiating impl &T methods #3261

Closed
@bblum

Description

@bblum

Here is some code that segfaults.

If I replace the impl with fn with(x: &X, blk: fn(...)) then the program is correctly rejected.

import either::*;
enum X = Either<(uint,uint),fn()>;
impl &X {
    fn with(blk: fn(x: &Either<(uint,uint),fn()>)) {
        blk(&**self)
    }
}
fn main() {
    let mut x = X(Right(main));
    do (&mut x).with |opt| {  // this should be illegal
        match *opt {
            Right(f) => {
                x = X(Left((0,0)));
                f()
            },
            _ => fail
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lifetimesArea: Lifetimes / regionsA-type-systemArea: Type systemI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions