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

regression: return is treated as a break in a breakable code #5612

Closed
scabug opened this issue Mar 26, 2012 · 8 comments
Closed

regression: return is treated as a break in a breakable code #5612

scabug opened this issue Mar 26, 2012 · 8 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Mar 26, 2012

Reported by Richard Emberson on scala-user, minimized:

object L extends Enumeration {
  val One, Two, Three = Value
}

class Foo {
  def foo(xs: List[L.Value]) {
    import scala.util.control.Breaks.{break, breakable}
    println("START for " + xs)
    breakable {
      for (x <- xs) {
        x match {
          case L.One => println("ONE"); return
          case L.Two => println("TWO")
          case L.Three => println("THREE"); break
        }
      }
    }
    println("FINISH")
  }
}

object Test {
  def main(args: Array[String]) {
    val f = new Foo()
    val l = List(L.Two, L.Two, L.One, L.Three)
    f.foo(l)
  }
}

in 2.10.0-M2:

START for List(Two, Two, One, Three)
TWO
TWO
ONE

in latest nightly (a532ba):
compiles with warning:

warning: non variable type-argument Unit in type pattern scala.runtime.NonLocalReturnControl[Unit] is unchecked since it is eliminated by erasure

output:

START for List(Two, Two, One, Three)
TWO
TWO
ONE
FINISH
@scabug
Copy link
Author

scabug commented Mar 26, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5612?orig=1
Reporter: @hubertp
Affected Versions: 2.10.0-M2

@scabug
Copy link
Author

scabug commented Mar 26, 2012

@hubertp said:
It seems to be caused by this catch block generated during uncurry for NonLocalReturnControl.
The old code:

} catch {
  case (ex @ (_: scala.runtime.NonLocalReturnControl[Foo.this._])) => if (ex.key().eq(nonLocalReturnKey1))
    ex.value().asInstanceOf[Unit]()
  else
    throw ex
}

vs the new one:

} catch {
  case (ex @ (_: scala.runtime.NonLocalReturnControl[Unit])) => if (ex.key().eq(nonLocalReturnKey1))
    ex.value()
  else
    throw ex
}

@scabug
Copy link
Author

scabug commented Mar 26, 2012

@paulp said:
I already tracked this down and reverted the commit which caused it, but that broke the build and the revert was unreverted.

See 5af2bf54d2 and 3db29dde05 .

The commit which caused it is 19a48510c .

The "non-variable type argument" spurious warning is unrelated.

@scabug
Copy link
Author

scabug commented Mar 27, 2012

@hubertp said:
Ah, the infamous revert of the revert. Thanks for the info.

@scabug
Copy link
Author

scabug commented Apr 30, 2012

Richard Emberson (rmemberson) said:
Wow, I guess I am really surprised that 2.10.0-M3 would be
released without first fixing this show-stopper.
I'd like to incorporate some of the new features being
highlighted in the 2.10.0-M3 but can not because a couple
of my libraries have failed to compile for over a month
due to the "fix" 19a48510c.
I kept waiting for this to be addressed so that I could
go back to using the git-head rather than 2.10.0-M2.

@scabug
Copy link
Author

scabug commented Apr 30, 2012

@SethTisue said:
I don't really know what a "milestone" is or should be, but I would agree that nothing with this bug should be called a release candidate.

@scabug
Copy link
Author

scabug commented Apr 30, 2012

@paulp said:
In principle milestones are time-based and indifferent to the presence or absence of any particular fix; the only milestone-specific effort is to endeavor to make sure it works with sbt, the ide, etc.

@scabug
Copy link
Author

scabug commented May 4, 2012

@paulp said:
aad6deae72

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

No branches or pull requests

2 participants