- Home /
Wierd problem with abstract classes and import statements in Javascript
Hey all,
I've run into a strange problem with my code. I want to create an abstract class with a private variable as a Dictionary but the code I'm using throws up a syntax error. I've narrowed it down to a problem with the combination of an import statement and the abstract keyword. For example:
import System.Collections.Generic;
abstract public class NewClass extends BaseClass { }
gives the error 'UCE0001: ';' expected. Insert a semicolon at the end.' on the 'abstract public class...' line but I have no idea why. Removing either the import statement or abstract keyword gets rid of the error.
Can anyone enlighten me as to why the error is there in the first place?
Thanks,
Wibbs
Is BaseClass also abstract? Can you use abstract on derived classes? On classes derived from non-abstract classes?
Answer by Mike 3 · Mar 22, 2011 at 06:05 AM
I don't think UnityScript supports abstract classes
abstract class BaseClass
{
}
by itself throws the same error, and
public abstract class BaseClass
{
}
throws an unexpected token error
On the other hand, I don't know how you're managing to get it compiling just by removing the import
This gets more strange. I thought it supported abstract classes. For example:
pragma strict
abstract public class BaseEvent
{
public function BaseEvent()
{
}
public function BaseEvent(timeStamp: long)
{
this.timeStamp = timeStamp;
}
public var id : String;
public var timeStamp : long;
}
doesn't throw an error and works fine. I've been assu$$anonymous$$g that this meant the abstract part works properly, but having just checked, Unity will happily let me create a BaseEvent, even though its marked as abstract.
Hah, that's fantastic. So it's basically just a syntax error or parsed out, either way unsupported.
Your answer
Follow this Question
Related Questions
Using functions of Inherited classes 3 Answers
How should I structure my unit class relationships? 1 Answer
Error UCE0001 ';' Expected. 1 Answer
Dreaded UCE0001 ';' error 2 Answers
Calling coroutines through pointers/"Function" class? 2 Answers