Means you have to declare a constructor which calls the super class constructor with required arguments - just like Java, different syntax
The msg parameter is typed as Str, not Str? which means null is not allowed (hard to tell from you code what is going on there)
AkcelistoMon 9 Jul 2012
1) I always think that compiler pastes ctor in my class if I dont.
This code
const class MyErr : Err{}
compiles into
const class MyErr : Err{
new make():super.make(){}
}
Probably, diff is in optional and required args. This not compiles too:
class A{
new make(Str? p := null){}
}
class B : A{
}
Ok. Now I understand 1).
2) May you give me more details? Why hard to tell? This is all code. I post my test a whole. I cant see msg in my test. I cant see null in my test. Where null is not allowed?
then I too would expect the following to work, but with an empty Str msg:
const class MyErr : Err {
new make() : super.make() {}
}
But as Akcelisto says, a NullErr is thrown.
It's weird, cos looking at the Err java code:
public static Err make() { return make("", (Err)null); }
it all looks good!
AkcelistoMon 9 Jul 2012
(1) is compiler feature: optional args became reqiured args in ctor inheritance when compiler pastes default ctor. Compiler cant paste default ctor with optional args.
(However, I think, compiler can be improved in this case.)
But (2) is bug. This code must not throw any exception:
class ErrTest : Test{
Void testMake(){
err := MyErr()
}
}
const class MyErr : Err{
new make():super.make(){}
}
This test must be successful.
brianMon 9 Jul 2012
Promoted to ticket #1942 and assigned to brian
Optional parameters still must be declared by subclasses, so that is by design.
I can't test that snippet code at the moment, but it shouldn't be compiling and failing in that way. It is probably related to Err getting implemented by hand in Java. So I will take a look.
brianSun 15 Jul 2012
Ticket resolved in 1.0.64
It was just a bug in the hand coded constructor for Err.java, Err.cs
Akcelisto Sun 8 Jul 2012
I write custom err and I meet two issue with err.
1) Why this is not compiled?
Compiler output:
However
sys::Err.make
is exists.2) Why this test is failed?
This compiles but throws err:
brian Sun 8 Jul 2012
Akcelisto Mon 9 Jul 2012
1) I always think that compiler pastes ctor in my class if I dont.
This code
compiles into
Probably, diff is in optional and required args. This not compiles too:
Ok. Now I understand 1).
2) May you give me more details? Why hard to tell? This is all code. I post my test a whole. I cant see
msg
in my test. I cant seenull
in my test. Wherenull
is not allowed?SlimerDude Mon 9 Jul 2012
Given that the
sys::Err
ctor isthen I too would expect the following to work, but with an empty Str msg:
But as Akcelisto says, a NullErr is thrown.
It's weird, cos looking at the Err java code:
it all looks good!
Akcelisto Mon 9 Jul 2012
(1) is compiler feature: optional args became reqiured args in ctor inheritance when compiler pastes default ctor. Compiler cant paste default ctor with optional args.
(However, I think, compiler can be improved in this case.)
But (2) is bug. This code must not throw any exception:
This test must be successful.
brian Mon 9 Jul 2012
Promoted to ticket #1942 and assigned to brian
Optional parameters still must be declared by subclasses, so that is by design.
I can't test that snippet code at the moment, but it shouldn't be compiling and failing in that way. It is probably related to Err getting implemented by hand in Java. So I will take a look.
brian Sun 15 Jul 2012
Ticket resolved in 1.0.64
It was just a bug in the hand coded constructor for Err.java, Err.cs
changeset