Aladdin - Scala Bugtracking
[#304] project: compiler priority: medium category: bug
submitter assigned to status date submitted
Michel Martin fixed 2004-03-09 16:58:44.0
subject Constant folder doesn't fold unary minus
code
object O {
  def f1 = -1;
  def f2 = 0-1;
  def f3 = f1 + f2;
}
what happened
The constant folder didn't consider f1 to be constant because unary minus is apparently not handled\
 by it. Here is the code after RefCheck:
[[syntax trees at uncurry (after refcheck)]]
// Scala source: bug_constantfolder_2.scala
final class O() extends java.lang.Object() with scala.ScalaObject() {
  final def f1: scala.Int = 1.$minus;
  final def f2: scala.Int = -1;
  final def f3: scala.Int = O.this.f1.$plus(-1);
  override def $tag(): scala.Int = 0
};
what expected A folded constant.
[back to overview]
Changes of this bug report
Martin  edited on  2004-04-16 15:13:17.0