Closed fdodino closed 8 years ago
Problem is here:
class UserException inherits wollok.lang.Exception {
constructor(mensaje) {
super(mensaje)
}
}
If I do
class UserException inherits wollok.lang.Exception {
constructor(mensaje) = super(mensaje)
}
problem is solved. But I should be able to write it both ways.
I'm not sure how it should behave, but I'm sure that those 2 syntaxes are not exactly equivalent. The second one has an implicit return, the first one doesn't. In order to be exactly equivalent, it should be:
class UserException inherits wollok.lang.Exception {
constructor(mensaje) {
return super(mensaje)
}
}
Ok, but you cannot define a return inside a constructor, otherwise you get an error: "you cannot return a value in constructor"
Nice-to-have: I would prefer not to redefine the constructor,if I can inherit it from Exception. But it doesn't work, I get "Wrong number of arguments. Should be new UserException"
They are not the same. Wollok doesn't have constructor delegation as part of the constructor's body. This shouldn't compile
constructor(mensaje) {
super(mensaje)
}
There's only one way to delegate and it is outside the body, before it, and after a = symbol
constructor(mensaje) = super(mensaje) {
...
}
Seems like we missed an static check to forbid writing super() within any constructor
This syntax is more similar to C# than to Java.
Steps to reproduce it. Create a Wollok Object:
Then start a REPL console and type:
you get