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

Cross-crate private methods can be called #3986

Closed
catamorphism opened this Issue Nov 16, 2012 · 5 comments

Comments

Projects
None yet
5 participants
@catamorphism
Contributor

catamorphism commented Nov 16, 2012

File a.rs:

mod kitties {
    pub struct cat {
        priv mut meows : uint
    }

    pub impl cat {
      priv fn nap() { for uint::range(1, 10000) |_i|{}}
    }

    pub fn cat(in_x : uint) -> cat {
        cat { meows: in_x }
    }

}

File b.rs:

extern mod b;
use b::kitties::*;

fn main() {
  let nyan : cat = cat(52);
  nyan.nap();
}

This compiles. It shouldn't, since nap is private.

@ghost ghost assigned catamorphism Nov 24, 2012

@pnkfelix

This comment has been minimized.

Show comment
Hide comment
@pnkfelix

pnkfelix Mar 25, 2013

Member

Not critical for 0.6; de-milestoning

Member

pnkfelix commented Mar 25, 2013

Not critical for 0.6; de-milestoning

@thestinger

This comment has been minimized.

Show comment
Hide comment
@thestinger

thestinger Apr 16, 2013

Contributor

This hits an ICE now.

Contributor

thestinger commented Apr 16, 2013

This hits an ICE now.

@pnkfelix

This comment has been minimized.

Show comment
Hide comment
@pnkfelix

pnkfelix Apr 27, 2013

Member

Nominating for a maturity milestone. I have not yet confirmed that it ICE's, but I will trust thestinger. If it ICE's, then I think it belongs with milestone 3: feature complete. (If it is not ICE'ing, then we need to be more aggressive and file it with milestone 2: backwards compatibility.)

Member

pnkfelix commented Apr 27, 2013

Nominating for a maturity milestone. I have not yet confirmed that it ICE's, but I will trust thestinger. If it ICE's, then I think it belongs with milestone 3: feature complete. (If it is not ICE'ing, then we need to be more aggressive and file it with milestone 2: backwards compatibility.)

@graydon

This comment has been minimized.

Show comment
Hide comment
@graydon

graydon May 9, 2013

Contributor

accepted for production-ready milestone

Contributor

graydon commented May 9, 2013

accepted for production-ready milestone

@cmr

This comment has been minimized.

Show comment
Hide comment
@cmr

cmr Jul 7, 2013

Member

Fixed:

a.rs:

pub struct Foo {
    a: uint
}

impl Foo {
    priv fn foo(&self) {
        println(fmt!("%u", self.a));
    }
}

b.rs:

extern mod a;

fn main() {
    let foo = a::Foo { a: 52 };
    foo.foo();
}
b.rs:5:4: 5:14 error: method `foo` is private
b.rs:5     foo.foo();
           ^~~~~~~~~~
error: aborting due to previous error
Member

cmr commented Jul 7, 2013

Fixed:

a.rs:

pub struct Foo {
    a: uint
}

impl Foo {
    priv fn foo(&self) {
        println(fmt!("%u", self.a));
    }
}

b.rs:

extern mod a;

fn main() {
    let foo = a::Foo { a: 52 };
    foo.foo();
}
b.rs:5:4: 5:14 error: method `foo` is private
b.rs:5     foo.foo();
           ^~~~~~~~~~
error: aborting due to previous error

@cmr cmr closed this Jul 7, 2013

@catamorphism catamorphism removed their assignment Jun 16, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment