Aladdin - Scala Bugtracking
[#568] project: compiler priority: low category: bug
submitter assigned to status date submitted
Burak Martin fixed 2006-04-22 01:12:45.0
subject compiler crash on mixin
code
package smotor.engine.config ;

import scala.collection.{ Map, mutable };

import scala.xml._;
import scala.xml.parsing.MarkupHandler;
import scala.xml.parsing.MarkupParser;

abstract class ConfigHandler extends MarkupHandler /*with MarkupParser*/ {
...
}
what happened

when compiling smotor (ant clean, then ant), the compiler dies with the exception. By pure instinct, I tried add\ ing the "with MarkupParser" bit (which would normally get mixed in again in a subclass, ConfigReader), and now i\ t compiles. Looks like a bug in the typechecker?

(please wait until I check in the stuff by morning 2006-04-22, otherwise you might get confused)

Buildfile: build.xml

init:
    [mkdir] Created dir: /localhome/buraq/svn/smotor.trunk/classes

build:
   [scalac] Compiling 18 source files to /localhome/buraq/svn/smotor.trunk/classes
   [scalac] exception when traversing smotor.engine.config.ConfigHandler with scala.xml.parsing.MarkupParser wit\
h scala.ScalaObject {
   [scalac]   private  val input : scala.io.Source = _;
   [scalac]   override   def input(): scala.io.Source = ConfigReader.this.input ;
   [scalac]   private  var ch : scala.Char = _;
   [scalac]   override  def ch(): scala.Char = ConfigReader.this.ch ;
   [scalac]   override  def ch_=(x$1: scala.Char): scala.Unit = ConfigReader.this.ch  = x$1;
   [scalac]   def externalSource(systemLiteral: java.lang.String): scala.io.Source = throw new smotor.engine.con\
fig.ConfigReaderError.this("external sources in config file not supported");
   [scalac]   override def nextch(): scala.Unit = if (ConfigReader.this.input().hasNext())
   [scalac]     ConfigReader.this.ch_=(ConfigReader.this.input().next());
   [scalac]   def init(): scala.Unit = ConfigReader.this.nextch();
   [scalac]   private  val preserveWS : scala.Boolean = _;
   [scalac]     def preserveWS(): scala.Boolean = ConfigReader.this.preserveWS ;
   [scalac]   override def reportSyntaxError(pos: scala.Int, str: java.lang.String): scala.Unit = throw new smot\
or.engine.config.ConfigReaderError.this(str);
   [scalac]   def this(filename: java.lang.String): smotor.engine.config.ConfigReader = {
   [scalac]     ConfigReader.this.input  = scala.io.Source.fromFile(filename);
   [scalac]     {
   [scalac]       ConfigReader.super.this();
   [scalac]       ()
   [scalac]     };
   [scalac]     ConfigReader.this./*TokenTests$class*/$init$();
   [scalac]     ConfigReader.this./*MarkupParser$class*/$init$();
   [scalac]     ConfigReader.this.ch  = ConfigReader.this.input().next();
   [scalac]     ConfigReader.this.preserveWS  = true;
   [scalac]     ()
   [scalac]   }
   [scalac] }
   [scalac] exception when traversing class ConfigReader extends smotor.engine.config.ConfigHandler with scala.x\
ml.parsing.MarkupParser with scala.ScalaObject {
   [scalac]   private  val input : scala.io.Source = _;
   [scalac]   override   def input(): scala.io.Source = ConfigReader.this.input ;
   [scalac]   private <local> var ch : scala.Char = _;
   [scalac]   override <accessor> def ch(): scala.Char = ConfigReader.this.ch ;
   [scalac]   override <accessor> def ch_=(x$1: scala.Char): scala.Unit = ConfigReader.this.ch  = x$1;
   [scalac]   def externalSource(systemLiteral: java.lang.String): scala.io.Source = throw new smotor.engine.con\
fig.ConfigReaderError.this("external sources in config file not supported");
   [scalac]   override def nextch(): scala.Unit = if (ConfigReader.this.input().hasNext())
   [scalac]     ConfigReader.this.ch_=(ConfigReader.this.input().next());
   [scalac]   def init(): scala.Unit = ConfigReader.this.nextch();
   [scalac]   private  val preserveWS : scala.Boolean = _;
   [scalac]     def preserveWS(): scala.Boolean = ConfigReader.this.preserveWS ;
   [scalac]   override def reportSyntaxError(pos: scala.Int, str: java.lang.String): scala.Unit = throw new smot\
or.engine.config.ConfigReaderError.this(str);
   [scalac]   def this(filename: java.lang.String): smotor.engine.config.ConfigReader = {
   [scalac]     ConfigReader.this.input  = scala.io.Source.fromFile(filename);
   [scalac]     {
   [scalac]       ConfigReader.super.this();
   [scalac]       ()
   [scalac]     };
   [scalac]     ConfigReader.this./*TokenTests$class*/$init$();
   [scalac]     ConfigReader.this./*MarkupParser$class*/$init$();
   [scalac]     ConfigReader.this.ch  = ConfigReader.this.input().next();
   [scalac]     ConfigReader.this.preserveWS  = true;
   [scalac]     ()
   [scalac]   }
   [scalac] }
   [scalac] exception when traversing package config {

... etc
what expected silent compilation, adding "with MarkupParser" should not be necessary
[back to overview]
Changes of this bug report
Martin  edited on  2006-04-25 16:48:18.0
The problem was the override of a variable `ch' in MarkupParser. This should not be legal as one of the variables becomes inaccessible. The corrected version of scalac disallows this code: engine/config/ConfigReader.scala:16 error: error overriding method ch in trait MarkupParser of type => scala.this.Char; method ch cannot override a mutable variable override var ch = input.next; ^ The fix in the program should of cousre be to simple re-assign char, i.e. drop the `override var' in the line override var ch = input.next; of class ConfigReader.