We support certain names that the Flex MXMLC compiler does not. In
particular, members of an object can use reserved words as names because
JavaScript allows that (historical note: JavaScript also didn't allow
reserved words as member names at the time that ES4/AS3 was being created).
However, if I remember correctly, JavaScript still does not allow reserved
words as local variable names, so naming a local variable "interface"
should indeed result in a compile-time error.

Just like other reserved words, "internal" should be allowed as a member
name, so that's technically a bug. I believe I tried to modify the compiler
to allow "internal" a while back (along with public/protected/private), but
it turns out that the parser handles these a bit differently than other
reserved words that we've allowed (like "delete" or "is"), and I couldn't
figure out what extra steps were needed for "internal" that weren't needed
for the others.

- Josh

On Wed, Mar 15, 2017 at 10:23 AM, Harbs <[email protected]> wrote:

> I think this is a bug:
>
> If have some code like this:
>
>         public function findInterfaces():Vector.<NetworkInterface>
>         {
>             var retVal:Vector.<NetworkInterface> = new
> Vector.<NetworkInterface>();
>             var interfaces:Object = someCodeWhichReturnsAnObject();
>             var x:String;
>             for(x in interfaces){
>                 var interface:NetworkInterface = new NetworkInterface();
>                 interface.displayName = x;
>                 interface.name = x;
>                 interface.active = true;
>                 var addresses = interfaces[x];
>                 for(var i:int=0;i<addresses.length;i++){
>                     var address:InterfaceAddress = new InterfaceAddress();
>                     address.address = addresses[i].address;
>                     address.broadcast = addresses[i].netmask;
>                     address.ipVersion = addresses[i].family;
>                     if(addresses[i].mac){
>                         interface.hardwareAddress = addresses[i].mac;
>                     }
>                     if(addresses[i].internal){
>                         interface.active = false;
>                     }
>
>                 }
>                 retVal.push(interface);
>             }
>
>             return retVal;
>         }
>
> And I’m getting errors like this:
>
>
>         Interface definitions must not be nested within class or other
> interface definitions.
>                 interface.active = true;
>         Expected IDENTIFIER but got '.'
>                 interface.active = true;
>         '=' is not allowed here
>                 interface.active = true;
>         if' is not allowed here
>                     if(addresses[i].internal){
>         'internal' is not allowed here
>                     if(addresses[i].internal){
>         Expected PAREN_CLOSE but got 'internal'
>                     if(addresses[i].internal){
>         ')' is not allowed here
>                     if(addresses[i].internal){
>
> Harbs

Reply via email to