You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
typestate sees break as applying to the outermost loop #2642
actually I think this is neither liveness nor typestate but rather typeck and something off in the (rather hokey) way that it tracks the notion of "bottom".
it seems to me that loops and complex constructs that may or may not be bottom should just have unit type. Something like ret or what have you can still have bottom type.
In this case, we need bottom to acknowledge that nothing will ever fall off the end of the outer loop, preventing the need for a dummy, dead code ret statement.
Yes, but the point of introducing loop was to make it possible to omit fails in some common cases... so I'm with Paul at least until I look at the typeck code and decide it's too hard to fix ;-)
Paul's example is more convincing. I guess we have to make it work due to the fact that loops are expressions and can appear in tail position in a block. sigh
Activity
nikomatsakis commentedon Jun 18, 2012
this may be a liveness bug?
catamorphism commentedon Jun 18, 2012
Maybe, but I'm pretty sure I know what the bug is if it's in typestate. @paulstansifer , can you post the error message?
nikomatsakis commentedon Jun 18, 2012
actually I think this is neither liveness nor typestate but rather typeck and something off in the (rather hokey) way that it tracks the notion of "bottom".
nikomatsakis commentedon Jun 18, 2012
this is the error that I see:
catamorphism commentedon Jun 18, 2012
Yeah, not a typestate error. I can still take a look, though.
nikomatsakis commentedon Jun 18, 2012
To be honest, I am not sure that the type system ought to be in the business of tracking bottom.
paulstansifer commentedon Jun 18, 2012
Oops, sorry folks. That's the same as the error I get.
paulstansifer commentedon Jun 18, 2012
It's really useful if you want to return from inside an otherwise infinite loop, which is what led me to this bug.
nikomatsakis commentedon Jun 18, 2012
but why are you "assigning" the loop to a local variable in the first place?
nikomatsakis commentedon Jun 18, 2012
it seems to me that loops and complex constructs that may or may not be bottom should just have unit type. Something like
retor what have you can still have bottom type.paulstansifer commentedon Jun 18, 2012
I probably should've reduced it to an example that looks more like the code I'm interested in:
In this case, we need bottom to acknowledge that nothing will ever fall off the end of the outer loop, preventing the need for a dummy, dead code
retstatement.eholk commentedon Jun 18, 2012
I think I usually just use
failif I need to convince the compiler that some code will never run.catamorphism commentedon Jun 19, 2012
Yes, but the point of introducing
loopwas to make it possible to omitfails in some common cases... so I'm with Paul at least until I look at the typeck code and decide it's too hard to fix ;-)nikomatsakis commentedon Jun 19, 2012
Paul's example is more convincing. I guess we have to make it work due to the fact that loops are expressions and can appear in tail position in a block. sigh
Auto merge of rust-lang#2642 - Rageking8:followup-for-pr-2640, r=Ralf…
Auto merge of rust-lang#2642 - Rageking8:followup-for-pr-2640, r=Ralf…
Merge pull request rust-lang#2642 from rust-lang/tshepang/sembr
Merge rust-lang#2642