Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-7792

Explicit return causes scalac -optimize to fail

    Details

    • Type: Bug
    • Status: Open
    • Priority: Critical
    • Resolution: Unresolved
    • Affects Version/s: Scala 2.10.2
    • Fix Version/s: None
    • Component/s: Optimizer
    • Labels:
      None
    • Environment:

      Java(TM) SE Runtime Environment (build 1.7.0_15-b03)
      Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
      OSX 10.8.4

      Description

      Given this code:

      object Return {
        def test(oi:Option[Int]):Option[String] =
          oi.map(i => return Some(i.toString))
      }
      

      When the return keyword is explicitly used and you try to compile it with -optimize, it causes the compiler to fail with the following message:

      could not find init in: Return.test

      The full trace is at https://gist.github.com/dkristian/6348965 (also attached).

      It compiles fine without the -optimize flag, and works with the flag if the method definition is changed to

        oi.map(i => i.toString)
      

      Discussion started at https://groups.google.com/forum/#!topic/scala-language/WTzjZ5dpPdo

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              kristian.domagala Kristian Domagala
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: