Aladdin - Scala Bugtracking
[#333] project: interpreter priority: low category: bug
submitter assigned to status date submitted
Burak Philippe fixed 2004-05-19 15:31:26.0
subject doesn't handle returns
code
object testInt with Application {

  def foo():Int = {
    var i = 10;
    while( i > 0 ) {
      i = i - 1;
      if( i == 5 ) return i;
    }
    return 0;
  }
  

  Console.println( foo() );

}
what happened
/tmp> scalaint 
  __ __  _      _
 (_ /   /_||   /_|   INTERPRETER
___)\__/  ||__/  |   (c) 2002-04, LAMP/EPFL
 
 version: 1.1.1.4
 type :? to get a list of all interpreter commands
 
> :load testInt.scala
> testInt
Exception in thread "main" scalac.ApplicationError: illegal tree: return i
        at scalac.util.Debug.abort(Debug.java:58)
        at scala.tools.scalai.ExpressionCompiler.object(ExpressionCompiler.java:217)
...
what expected 5 to be printed
[back to overview]
Changes of this bug report
Gilles  edited on  2006-03-27 17:50:41.0
Fixed in Scala2