When I do the following the compiler fails to give an error
class A
{
Str? val1
}
class B : A
{
Str? val2
}
class Test
{
Void main()
{
A[] aa := [A(),A()]
someFunc(aa)
}
Void someFunc(B[] para)
{
para.each |elem|
{
echo(elem.val2)
}
}
}
brianWed 26 Oct 2011
That is by design because the type system only flags types errors that are known to be wrong at compile time. Same principle without using lists:
class Test
{
static Void foo(Str x) {}
static Void main() { Obj x := 3; foo(x) }
}
jessevdamWed 26 Oct 2011
That is true, but Hmm I had somewhere a case where it somehow failed in JS, but can not find it any more :(
jessevdam Wed 26 Oct 2011
When I do the following the compiler fails to give an error
brian Wed 26 Oct 2011
That is by design because the type system only flags types errors that are known to be wrong at compile time. Same principle without using lists:
jessevdam Wed 26 Oct 2011
That is true, but Hmm I had somewhere a case where it somehow failed in JS, but can not find it any more :(