Static extensions shadow abstract's own variables?

33 views
Skip to first unread message

Ondřej Műller

unread,
Feb 16, 2017, 4:13:26 PM2/16/17
to Haxe
Try the following in try.haxe.org:

using Lambda;
class Test {
   
static function main() {}
}
class TYPE {
   
public function new() {}
   
public function iterator():Iterator<Int> return new IntIterator(0, 1);
}
abstract ABSTRACT(TYPE) {
   
public var array(get, never):Bool;
   
function get_array() return true;
   
   
public function new() {
       
this = new TYPE();
        $type
(array);
        $type
(this.array);
   
}
}

Output:

Test.hx:15: characters 14-19 : Warning : Void -> Array<Int>
Test.hx:16: characters 14-24 : Warning : Void -> Array<Int>

It is the Lambda.array<A>(it:Iterable<A>):Array<A> function.
This means that "using" just deletes possible field names, even inside the definition of the abstract.
I encountered this when an order(get, never):Int of a Matrix class showed up as 20 errors of "order : Iterable<Int> -> Iterable<math.vectors.Int2> should be Int" because of an iterator. Am I just not allowed to use that name?
I can see "this.array" being the static extension, but not "array".

Dan Korostelev

unread,
Feb 16, 2017, 4:47:29 PM2/16/17
to Haxe
> I can see "this.array" being the static extension, but not "array".

That looks like a bug! Could you create an issue about it?

пятница, 17 февраля 2017 г., 0:13:26 UTC+3 пользователь Ondřej Műller написал:

Ondřej Műller

unread,
Feb 16, 2017, 5:15:57 PM2/16/17
to Haxe
Reply all
Reply to author
Forward
0 new messages