Skip to content

Break with Value causes ICE #44416

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
CasualX opened this issue Sep 8, 2017 · 3 comments
Closed

Break with Value causes ICE #44416

CasualX opened this issue Sep 8, 2017 · 3 comments

Comments

@CasualX
Copy link

CasualX commented Sep 8, 2017

In reply to a comment on /r/rust I tried to write a macro to simulate for ... else and this causes an ICE

I tried this code: playground

macro_rules! for_else {
    ($i:ident in $iter:expr; $body:tt else $e:expr) => {
        'outer: loop {
            for $i in $iter $body
            break 'outer $e;
        }
    };
}

fn main() {
    let result = for_else!(i in 0..10; {
        break 'outer 2.71828;
    }
    else {
        3.141592
    });
    println!("Hello, {}!", result);
}

I expected to see this happen: This was a first attempt at a for_else macro, so I'm not sure what I expected! Certainly not an ICE however

Instead, this happened:

   Compiling playground v0.0.1 (file:///playground)
error[E0426]: use of undeclared label `'outer`
  --> src/main.rs:12:15
   |
12 |         break 'outer 2.71828;
   |               ^^^^^^ undeclared label `'outer`

error: internal compiler error: /checkout/src/librustc_typeck/check/mod.rs:1984: no type for node 16: expr 2.71828 (id=16) in fcx 0x7fe29eff3670

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.20.0 (f3d6973f4 2017-08-27) running on x86_64-unknown-linux-gnu

thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:489:8
note: Run with `RUST_BACKTRACE=1` for a backtrace.

error: Could not compile `playground`.

To learn more, run the command again with --verbose.

Meta

Whatever's running today on the playground.

@est31
Copy link
Member

est31 commented Sep 8, 2017

This is fixed on nightly + beta. This is a dupe of #43162 and was likely fixed by #43745.

@CasualX
Copy link
Author

CasualX commented Sep 8, 2017

Ah, my bad. I admittedly didn't look very far for existing issues...

The fact that this is an ICE in Stable Rust is of no concern?

@CasualX CasualX closed this as completed Sep 8, 2017
@est31
Copy link
Member

est31 commented Sep 8, 2017

The fact that this is an ICE in Stable Rust is of no concern?

An ICE in stable Rust obviously has a higher priority but an ICE is a bug regardless of whether its in stable or nightly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants