Skip to content
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

internal compiler error: self wasn't mapped to a def?! #6642

Closed
indutny opened this issue May 20, 2013 · 4 comments
Closed

internal compiler error: self wasn't mapped to a def?! #6642

indutny opened this issue May 20, 2013 · 4 comments
Labels
A-resolve Area: Name resolution I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@indutny
Copy link
Contributor

indutny commented May 20, 2013

This error happens when trying to access self within local/embedded function:

struct A;
impl A {
  fn m(&self) {
    fn x() {
      self.m()
    }
  }
}
@pnkfelix
Copy link
Member

When I attempt to replicate the bug, I get the following output from rustc:

% ./x86_64-apple-darwin/stage2/bin/rustc -v
./x86_64-apple-darwin/stage2/bin/rustc 0.8-pre (9c22f65 2013-07-15 05:01:19 -0700)
host: x86_64-apple-darwin
% ./x86_64-apple-darwin/stage2/bin/rustc /tmp/foo.rs
/tmp/foo.rs:4:13: 4:18 error: can't capture dynamic environment in a fn item; use the || { ... } closure form instead
/tmp/foo.rs:4     fn x() { self.m() }
                           ^~~~~
/tmp/foo.rs:4:13: 4:18 error: internal compiler error: self wasn't mapped to a def?!
/tmp/foo.rs:4     fn x() { self.m() }
                           ^~~~~
% 

The ICE is indeed disturbing, but the earlier error indicates that something is awry in the code.

When I changed the code by replacing the fn x() { ... } with let x = || { ... }, the code seems to compile fine...

@pnkfelix
Copy link
Member

(not closing since we should still try to stamp out the ICE.)

@bblum
Copy link
Contributor

bblum commented Aug 14, 2013

Just ran into this myself. Confirming.

@ghost ghost assigned bblum Aug 21, 2013
@bblum
Copy link
Contributor

bblum commented Aug 21, 2013

easy to fix this

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

No branches or pull requests

3 participants