royale-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Harbs <harbs.li...@gmail.com>
Subject Re: Extraneous Number cast
Date Sun, 17 Dec 2017 09:31:46 GMT
I just found another bug which is likely related:

The following AS:
delete range.children()[j];

Compiles (incorrectly) to the following JS:
delete range.children()[j];

While:
var childrenList:XMLList = range.children();
delete childrenList[j];

compiles (correctly) to:
var /** @type {XMLList} */ childrenList = range.children();
childrenList.removeChild(j);

It seems like XML.children() cannot be correctly inferred by the compiler as an XMLList type.

Harbs

> On Dec 17, 2017, at 11:17 AM, Harbs <harbs.lists@gmail.com> wrote:
> 
> The following code:
> var range:XML;
> // etc.
> var childLen:int = range.children().length();
> 
> compiles to:
> var /** @type {XML} */ range;
> // etc.
> var /** @type {number} */ childLen = Number(range.children().length());
> 
> I don’t see why the Number() cast is being added both childLen and children().length()
are typed as ints.
> 
> Am I correct in assuming that this is a bug?
> 
> Harbs


Mime
View raw message