Repository navigation
ICE on loop {|_: [_; continue]| {}} #51761
Description
Activity
- addedI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
on Jun 24, 2018 Counterintuitively, this should probably compile successfully. It's not surprising that it's not working, though: it's a really weird edge case. I'll look into it.
I don't think it should compile successfully. The
continueis in an array length constant expression inside the closure's signature. Therefore, it's not part of the loop body and should cause an "continue outside of loop" error.I feel perhaps control-flow should just not be allowed inside type-level constants like this. That seems like the most logical decision. In which case, we should just add a new error for this.
Edit: Just saw @rkruppe's comment. I agree, though I'm not sure there's precedent for that or not? Is there an existing error we can make us of?
As I said, I believe this is a plain old "continue outside of loop" errors. The
continuetoken is lexically within theloop { ... }, but it's not part of the loop body, so it's invalid without even considering that it's supposed to be a constant. It's morally the same asloop { fn foo() { continue } }.What about the
breakversion?
Not sure if the fix is applied in the latest nightly, but this still ICE's:
#51707Rewritting it using a
loop {}instead ofwhile:fn main() { loop { |_: [_; break] | {} } }
@DutchGhost that's fixed by @varkor 's PR #51731 . The fix is not in nightly yet, not even merged. I've applied the PR locally in order to test whether the
loop {loop {|_: [_; continue]| {}} }bug still exists.It would probably make sense if @varkor would also fix the break version right away.
- added a commit that references this issue
on Jul 2, 2018 - added a commit that references this issue
on Jul 5, 2018
The following code ICEs on
nightly,stableandbeta:The ICE message is:
As of filing this bug, PR #51731 does not fix it. If I apply it, I'm getting: