This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Compiler error: missing parameter type

2 replies
Anders Bach Nielsen
Joined: 2008-12-17,
User offline. Last seen 42 years 45 weeks ago.

Hi

Now that I have a compiler that accepts the new early defs syntax, I
want to add use cases so that I can check as many situations as
possible. This is no problem, but while testing one of my test cases I
ran into a strange compiler error message

The test program is

trait NeedsXEarly {
val x: Int
super
}

class Foo1 extends NeedsXEarly {
val x = 1
super
}

class Foo2 extends NeedsXEarly {
val x = 1
super;
}

This uses the new early defs syntax with the super keywords as the
delimiter between the early defs part (first) and the normal template
body (last). This example has the special feature that NeedsXEarly is a
trait and declares val x as abstract. Compiling this program I get

-(~/scala/earlydefs)-?>./build/pack/bin/scalac test/files/pos/needstypeearly3.scala -Xprompt
error: missing parameter type
r)esume, a)bort: a
exception when typing abstract trait NeedsXEarly extends scala.AnyRef {
val x
}, pt = ?
exception when typing package {
abstract trait NeedsXEarly extends scala.AnyRef {
val x
};
class Foo1 extends NeedsXEarly with scala.ScalaObject {
val x = _;
def () = {
val x = 1;
super.();
()
}
};
class Foo2 extends NeedsXEarly with scala.ScalaObject {
val x = _;
def () = {
val x = 1;
super.();
()
}
}
}, pt = ?
Exception in thread "main" java.lang.Error: user abort
at scala.tools.nsc.reporters.ConsoleReporter.displayPrompt(ConsoleReporter.scala:122)
at scala.tools.nsc.reporters.AbstractReporter.info0(AbstractReporter.scala:42)
at scala.tools.nsc.reporters.Reporter.error(Reporter.scala:46)
at scala.tools.nsc.CompilationUnits$CompilationUnit.error(CompilationUnits.scala:60)
at scala.tools.nsc.typechecker.Contexts$Context.error(Contexts.scala:304)
at scala.tools.nsc.typechecker.Namers$Namer.typeSig(Namers.scala:1094)
at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$getterTypeCompleter$1.apply(Namers.scala:483)
at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$getterTypeCompleter$1.apply(Namers.scala:481)
at scala.tools.nsc.typechecker.Namers$$anon$1.complete(Namers.scala:1246)
at scala.tools.nsc.symtab.Symbols$Symbol.info(Symbols.scala:688)
at scala.tools.nsc.symtab.Symbols$Symbol.initialize(Symbols.scala:797)
at scala.tools.nsc.typechecker.Typers$Typer.addGetterSetter(Typers.scala:1259)
at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$11.apply(Typers.scala:1343)
at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$11.apply(Typers.scala:1343)
at scala.collection.generic.TraversableTemplate$$anonfun$flatMap$1.apply(TraversableTemplate.scala:164)
at scala.collection.generic.TraversableTemplate$$anonfun$flatMap$1.apply(TraversableTemplate.scala:164)
at scala.collection.generic.LinearSequenceTemplate$class.foreach(LinearSequenceTemplate.scala:81)
at scala.collection.immutable.List.foreach(List.scala:26)
at scala.collection.generic.TraversableTemplate$class.flatMap(TraversableTemplate.scala:164)
at scala.collection.immutable.List.flatMap(List.scala:26)
at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1343)
at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:1214)
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3460)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:3733)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:3775)
at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:1748)
at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$21.apply(Typers.scala:1805)
at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$21.apply(Typers.scala:1805)
at scala.collection.immutable.List$.loop$4(List.scala:714)
at scala.collection.immutable.List$.mapConserve(List.scala:731)
at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:1805)
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3456)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:3733)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:3775)
at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$2.apply(Analyzer.scala:80)
at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:322)
at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$2$$anonfun$run$1.apply(Analyzer.scala:50)
at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$2$$anonfun$run$1.apply(Analyzer.scala:50)
at scala.collection.Iterator$class.foreach(Iterator.scala:500)
at scala.collection.mutable.ListBuffer$$anon$1.foreach(ListBuffer.scala:280)
at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$2.run(Analyzer.scala:50)
at scala.tools.nsc.Global$Run.compileSources(Global.scala:809)
at scala.tools.nsc.Global$Run.compile(Global.scala:883)
at scala.tools.nsc.Main$.process(Main.scala:73)
at scala.tools.nsc.Main$.main(Main.scala:87)
at scala.tools.nsc.Main.main(Main.scala)

My problem with this is the error message:

error: missing parameter type

And it is generated from Namers.scala line 1094

However it seems to origin from the typer in the addSetterGetter method
at line 1258. Here the line reads

// todo: potentially dangerous not to duplicate the trees and clone the symbols / types.
getter.setAnnotations(value.initialize.annotations)
^^^^
The value that is initialized here, it the val x in the trait, but why
this gives a missing parameter type error I can not see. The code is
located in the earlydefs branch, but is very similar to the code in
trunk except for some parser changes!

/Anders

rytz
Joined: 2008-07-01,
User offline. Last seen 45 weeks 5 days ago.
Re: Compiler error: missing parameter type


On Tue, Jun 2, 2009 at 14:00, Anders Bach Nielsen <andersbach.nielsen@epfl.ch> wrote:
Hi

Now that I have a compiler that accepts the new early defs syntax, I
want to add use cases so that I can check as many situations as
possible. This is no problem, but while testing one of my test cases I
ran into a strange compiler error message

The test program is

trait NeedsXEarly {
 val x: Int
 super
}

class Foo1 extends NeedsXEarly {
 val x = 1
 super
}

class Foo2 extends NeedsXEarly {
 val x = 1
 super;
}

This uses the new early defs syntax with the super keywords as the
delimiter between the early defs part (first) and the normal template
body (last). This example has the special feature that NeedsXEarly is a
trait and declares val x as abstract. Compiling this program I get

-(~/scala/earlydefs)-?>./build/pack/bin/scalac test/files/pos/needstypeearly3.scala -Xprompt
error: missing parameter type
r)esume, a)bort: a
exception when typing abstract trait NeedsXEarly extends scala.AnyRef {
 <stable> <accessor> val x
}, pt = ?
exception when typing package <empty> {
 abstract trait NeedsXEarly extends scala.AnyRef {
   <stable> <accessor> val x
 };
 class Foo1 extends NeedsXEarly with scala.ScalaObject {
   val x = _;
   def <init>() = {
     val x = 1;
     super.<init>();
     ()
   }
 };
 class Foo2 extends NeedsXEarly with scala.ScalaObject {
   val x = _;
   def <init>() = {
     val x = 1;
     super.<init>();
     ()
   }
 }
}, pt = ?
Exception in thread "main" java.lang.Error: user abort
       at scala.tools.nsc.reporters.ConsoleReporter.displayPrompt(ConsoleReporter.scala:122)
       at scala.tools.nsc.reporters.AbstractReporter.info0(AbstractReporter.scala:42)
       at scala.tools.nsc.reporters.Reporter.error(Reporter.scala:46)
       at scala.tools.nsc.CompilationUnits$CompilationUnit.error(CompilationUnits.scala:60)
       at scala.tools.nsc.typechecker.Contexts$Context.error(Contexts.scala:304)
       at scala.tools.nsc.typechecker.Namers$Namer.typeSig(Namers.scala:1094)
       at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$getterTypeCompleter$1.apply(Namers.scala:483)
       at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$getterTypeCompleter$1.apply(Namers.scala:481)
       at scala.tools.nsc.typechecker.Namers$$anon$1.complete(Namers.scala:1246)
       at scala.tools.nsc.symtab.Symbols$Symbol.info(Symbols.scala:688)
       at scala.tools.nsc.symtab.Symbols$Symbol.initialize(Symbols.scala:797)
       at scala.tools.nsc.typechecker.Typers$Typer.addGetterSetter(Typers.scala:1259)
       at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$11.apply(Typers.scala:1343)
       at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$11.apply(Typers.scala:1343)
       at scala.collection.generic.TraversableTemplate$$anonfun$flatMap$1.apply(TraversableTemplate.scala:164)
       at scala.collection.generic.TraversableTemplate$$anonfun$flatMap$1.apply(TraversableTemplate.scala:164)
       at scala.collection.generic.LinearSequenceTemplate$class.foreach(LinearSequenceTemplate.scala:81)
       at scala.collection.immutable.List.foreach(List.scala:26)
       at scala.collection.generic.TraversableTemplate$class.flatMap(TraversableTemplate.scala:164)
       at scala.collection.immutable.List.flatMap(List.scala:26)
       at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1343)
       at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:1214)
       at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3460)
       at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:3733)
       at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:3775)
       at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:1748)
       at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$21.apply(Typers.scala:1805)
       at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$21.apply(Typers.scala:1805)
       at scala.collection.immutable.List$.loop$4(List.scala:714)
       at scala.collection.immutable.List$.mapConserve(List.scala:731)
       at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:1805)
       at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3456)
       at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:3733)
       at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:3775)
       at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$2.apply(Analyzer.scala:80)
       at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:322)
       at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$2$$anonfun$run$1.apply(Analyzer.scala:50)
       at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$2$$anonfun$run$1.apply(Analyzer.scala:50)
       at scala.collection.Iterator$class.foreach(Iterator.scala:500)
       at scala.collection.mutable.ListBuffer$$anon$1.foreach(ListBuffer.scala:280)
       at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$2.run(Analyzer.scala:50)
       at scala.tools.nsc.Global$Run.compileSources(Global.scala:809)
       at scala.tools.nsc.Global$Run.compile(Global.scala:883)
       at scala.tools.nsc.Main$.process(Main.scala:73)
       at scala.tools.nsc.Main$.main(Main.scala:87)
       at scala.tools.nsc.Main.main(Main.scala)

My problem with this is the error message:

error: missing parameter type

And it is generated from Namers.scala line 1094

However it seems to origin from the typer in the addSetterGetter method
at line 1258. Here the line reads

// todo: potentially dangerous not to duplicate the trees and clone the symbols / types.
getter.setAnnotations(value.initialize.annotations)
                         ^^^^
The value that is initialized here, it the val x in the trait, but why
this gives a missing parameter type error I can not see. The code is
located in the earlydefs branch, but is very similar to the code in
trunk except for some parser changes!

/Anders


it looks like the type part of the ValDef (tpt) is empty in the type completer, does it
gets lost during some transformation?

   abstract trait NeedsXEarly extends scala.AnyRef {
      <stable> <accessor> val x
    }, pt = ?

can you try printing the tree after parser, namer and typer (using -Xprint:phase)?


Anders Bach Nielsen
Joined: 2008-12-17,
User offline. Last seen 42 years 45 weeks ago.
Re: Compiler error: missing parameter type

> it looks like the type part of the ValDef (tpt) is empty in the type
> completer, does it
> gets lost during some transformation?
> abstract trait NeedsXEarly extends scala.AnyRef {
> val x
> }, pt = ?
>
> can you try printing the tree after parser, namer and typer (using
> -Xprint:phase)?

So I have been working on this now for a while, but it still eludes me
why this situation happens

With this smaller test program

trait NeedsXEarly {
val x: Int
var y: Int
super
val s: Int
var t: Int
}

Running with this command

./build/pack/bin/scalac test/files/pos/needstypeearly3.scala -Xprint:typer

I get the following output

In namer: x has flags
In namer: accflags
In namer: y has flags
In namer: accflags
In namer: s has flags
In namer: accflags
In namer: t has flags
In namer: accflags
In typer: add get/set for x with flags
error: missing parameter type
In typer: add get/set for y with flags

error: missing parameter type
error: missing parameter type
In typer: add get/set for s with flags
In typer: add get/set for t with flags
[[syntax trees at end of typer]]// Scala source: needstypeearly3.scala
package {
abstract trait NeedsXEarly extends scala.AnyRef {
def x: ;
def y: ;
def y_=(x$1: ): Unit;
def s: Int;
def t: Int;
def t_=(x$1: Int): Unit
}
}

three errors found

The outputs in namer and in typer are just to see what the namer and
typer sees and what modifiers the valdefs have. Apprantly the difference
here is if the val/var has a PRESUPER modifier or not! But why....

Any surgestions are welcome...

/Anders

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland