Error message confusing when overriding a constructor
Migrated from http://lampsvn.epfl.ch/trac/scala/ticket/396
Reporter fjanon
I am using Eclipse with the plugin 2.4.3 core and Compiler plugin 2.6.9.RC412860.
When overriding a constructor, I didn't call another constructor as the first statement. I get two messages not very indicative of the issue:
Severity and Description Path Resource Location Creation Time Id
'(' expected but ';' found. DownstreamScala/src/downstream TimePeriod.scala line 11 1200900796501 55
'this' expected but 'val' found. DownstreamScala/src/downstream TimePeriod.scala line 10 1200900796501 56
package downstream;
import java.util.Date
class TimePeriod(start: Date, end: Date) {
def startDate = start
def endDate = end
def this(timePeriod: TimePeriod) = this(timePeriod.startDate, timePeriod.endDate)
def this(OffFor: long) =
{
val someTime = 1000
this(new Date(), new Date())
}
}
When I comment out the "val someTime = 1000" line, the errors go away, which is normal.
Reporter fjanon
I am using Eclipse with the plugin 2.4.3 core and Compiler plugin 2.6.9.RC412860.
When overriding a constructor, I didn't call another constructor as the first statement. I get two messages not very indicative of the issue:
Severity and Description Path Resource Location Creation Time Id
'(' expected but ';' found. DownstreamScala/src/downstream TimePeriod.scala line 11 1200900796501 55
'this' expected but 'val' found. DownstreamScala/src/downstream TimePeriod.scala line 10 1200900796501 56
package downstream;
import java.util.Date
class TimePeriod(start: Date, end: Date) {
def startDate = start
def endDate = end
def this(timePeriod: TimePeriod) = this(timePeriod.startDate, timePeriod.endDate)
def this(OffFor: long) =
{
val someTime = 1000
this(new Date(), new Date())
}
}
When I comment out the "val someTime = 1000" line, the errors go away, which is normal.
Leave a comment
on 2008-01-20 22:38 *
By tracImporter
Trac author: fjanon
Sorry, I was referring to the first error message:
Severity and Description Path Resource Location Creation Time Id '(' expected but ';' found
Sorry, I was referring to the first error message:
Severity and Description Path Resource Location Creation Time Id '(' expected but ';' found
on 2008-04-20 04:40 *
By tracImporter
Trac author: mcdirmid
This is a compiler problem, not plugin. bumping back to devteam.
This is a compiler problem, not plugin. bumping back to devteam.
Trac author: rytz
Seems to work now. The current compiler (2.7.1.RC1) gives a nice error message:
Seems to work now. The current compiler (2.7.1.RC1) gives a nice error message:
t0396.scala:11: error: 'this' expected but 'val' found.
val someTime = 1000
^
the same is true for the (new) eclipse plugin.
on 2009-01-14 04:54 *
By tracImporter
Closed As: worksforme