[FlexJS] Compiler doesn't recognize reserved JS words like 'enum'

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[FlexJS] Compiler doesn't recognize reserved JS words like 'enum'

Olaf Krueger
Hi,
I've stumbled over the issue that the compiler doesn't recognize the reserved JS word 'enum'.
Instead, it just returns just a 'Parse error' without any hints that 'enum' is a reserved JS keyword [1]

Is it a big deal to teach the compiler all the reserved JS keywords [2].
I found something like that for the AS3 reserved words inside the compiler (as3ReservedWords) but nothing for the JS side... maybe there's already something like this?

Thanks,
Olaf

[1] https://snag.gy/sqGW95.jpg
[2] https://www.w3schools.com/js/js_reserved.asp
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [FlexJS] Compiler doesn't recognize reserved JS words like 'enum'

piotrz
Hi Olaf :),

How this failing fragment of code look like ? Could you post it on https://paste.apache.org/ ?

Thanks,
Piotr
Apache Flex PMC
piotrzarzycki21@gmail.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [FlexJS] Compiler doesn't recognize reserved JS words like 'enum'

Olaf Krueger
Hey Piotr,
the check-in procedure in Miami was done really quick, much faster than in Germany.
So I've had some time to revive the work on my PureMVC EmployeeAdmin FlexJS port ;-)

>How this failing fragment of code look like ? Could you post it on https://paste.apache.org/ ?

In my case, it occurs because a method parameter is named 'enum' [1].
But it's the same if you try to declare a variable, name it 'enum' and do something with it.
It seems that the compiler error messages differ depending on how 'enum' is used but it's always a 'Parse error'.

Of course, it's no problem to fix this by renaming 'enum' but I could imagine that it would helpful
for app developers to get an 'Reserved word' hint by the compiler.

Thanks,
Olaf

[1]
https://paste.apache.org/9Vun



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [FlexJS] Compiler doesn't recognize reserved JS words like 'enum'

piotrz
Olaf,

In that case one thought which came to me is to try COMPILE::JS tag for method, but as I remember it wasn't working in the end application. I need to try myself and raise jira probably.

Piotr
Apache Flex PMC
piotrzarzycki21@gmail.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [FlexJS] Compiler doesn't recognize reserved JS words like 'enum'

Josh Tynjala
There are a number of reserved words in ActionScript that can't be used as
identifiers, but they are allowed in JavaScript. We've been trying to
support each of them in the compiler whenever someone needs a new one. It
sounds like enum may be one of those that JavaScript allows that
ActionScript currently doesn't.

ActionScript and JavaScript used to behave the same way with reserved
words, but starting with ECMAScript 5, JavaScript removed some reserved
words from the list and also started allowing reserved words as identifiers
in certain specific situations. We've already modified the Falcon compiler
to allow several new identifiers, and it's not too difficult to add more.
We ran into trouble when trying to allow public, private, and internal, but
others that aren't namespaces have been fine.

- Josh

On Mon, May 22, 2017 at 7:08 AM, piotrz <[hidden email]> wrote:

> Olaf,
>
> In that case one thought which came to me is to try COMPILE::JS tag for
> method, but as I remember it wasn't working in the end application. I need
> to try myself and raise jira probably.
>
> Piotr
>
>
>
> -----
> Apache Flex PMC
> [hidden email]
> --
> View this message in context: http://apache-flex-
> development.2333347.n4.nabble.com/FlexJS-Compiler-doesn-t-
> recognize-reserved-JS-words-like-enum-tp61735p61740.html
> Sent from the Apache Flex Development mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [FlexJS] Compiler doesn't recognize reserved JS words like 'enum'

Christofer Dutz
Hi,

Would it be possible to have separate lists of these words and to activate these in the individual compilations?
I guess the stream will definitely direct towards more people migrating to JS so I think we shouldn’t prohibit flash related reserver words in the js world.

What do you think?

Chris

Am 22.05.17, 17:04 schrieb "Josh Tynjala" <[hidden email]>:

    There are a number of reserved words in ActionScript that can't be used as
    identifiers, but they are allowed in JavaScript. We've been trying to
    support each of them in the compiler whenever someone needs a new one. It
    sounds like enum may be one of those that JavaScript allows that
    ActionScript currently doesn't.
   
    ActionScript and JavaScript used to behave the same way with reserved
    words, but starting with ECMAScript 5, JavaScript removed some reserved
    words from the list and also started allowing reserved words as identifiers
    in certain specific situations. We've already modified the Falcon compiler
    to allow several new identifiers, and it's not too difficult to add more.
    We ran into trouble when trying to allow public, private, and internal, but
    others that aren't namespaces have been fine.
   
    - Josh
   
    On Mon, May 22, 2017 at 7:08 AM, piotrz <[hidden email]> wrote:
   
    > Olaf,
    >
    > In that case one thought which came to me is to try COMPILE::JS tag for
    > method, but as I remember it wasn't working in the end application. I need
    > to try myself and raise jira probably.
    >
    > Piotr
    >
    >
    >
    > -----
    > Apache Flex PMC
    > [hidden email]
    > --
    > View this message in context: http://apache-flex-
    > development.2333347.n4.nabble.com/FlexJS-Compiler-doesn-t-
    > recognize-reserved-JS-words-like-enum-tp61735p61740.html
    > Sent from the Apache Flex Development mailing list archive at Nabble.com.
    >
   

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [FlexJS] Compiler doesn't recognize reserved JS words like 'enum'

Olaf Krueger
In reply to this post by Josh Tynjala
Hi,

>It sounds like enum may be one of those that JavaScript allows that ActionScript currently doesn't.

I've checked it out and it turns out that for both (AS3 and JS, ECMAScript5) 'enum' is flagged as future reserved
keyword [1][2].
Does is makes sense to just add it to as3ReservedWords [3]?

Thanks,
Olaf

[1] https://www.ecma-international.org/ecma-262/5.1/
[1a] https://snag.gy/BLv4yX.jpg
[2] http://help.adobe.com/en_US/as3/learn/WS5b3ccc516d4fbf351e63e3d118a9b90204-
7f9b.html#WS5b3ccc516d4fbf351e63e3d118a9b90204-7f6e
[2a] https://snag.gy/p6r7av.jpg
[3] https://github.com/apache/flex-falcon/blob/7137de6b19cd11630ee1ef29f7a9164166e35b10/flex-compiler-oem/src/main/java/flex2/compiler/mxml/lang/StandardDefs.java#L623
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [FlexJS] Compiler doesn't recognize reserved JS words like 'enum'

Christofer Dutz
Really supporting “enums” would be super-cool anyway ;-)

Chris

Am 23.05.17, 09:08 schrieb "Olaf Krueger" <[hidden email]>:

    Hi,
   
    >It sounds like enum may be one of those that JavaScript allows that
    ActionScript currently doesn't.
   
    I've checked it out and it turns out that for both (AS3 and JS, ECMAScript5)
    'enum' is flagged as future reserved
    keyword [1][2].
    Does is makes sense to just add it to as3ReservedWords [3]?
   
    Thanks,
    Olaf
   
    [1] https://www.ecma-international.org/ecma-262/5.1/
    [1a] https://snag.gy/BLv4yX.jpg
    [2]
    http://help.adobe.com/en_US/as3/learn/WS5b3ccc516d4fbf351e63e3d118a9b90204-
    7f9b.html#WS5b3ccc516d4fbf351e63e3d118a9b90204-7f6e
    [2a] https://snag.gy/p6r7av.jpg
    [3]
    https://github.com/apache/flex-falcon/blob/7137de6b19cd11630ee1ef29f7a9164166e35b10/flex-compiler-oem/src/main/java/flex2/compiler/mxml/lang/StandardDefs.java#L623
   
   
   
   
    --
    View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-Compiler-doesn-t-recognize-reserved-JS-words-like-enum-tp61735p61758.html
    Sent from the Apache Flex Development mailing list archive at Nabble.com.
   

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [FlexJS] Compiler doesn't recognize reserved JS words like 'enum'

Olaf Krueger
In reply to this post by Olaf Krueger
>I guess the stream will definitely direct towards more people migrating to JS so I think we shouldn’t >prohibit flash related reserver words in the js world.

I'm confused.
Do you mean that we should allow using AS3 reserved words if they are allowed in the JS world?
Wouldn't that mean that AS3 does not work fine at the end?

Thanks,
Olaf
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [FlexJS] Compiler doesn't recognize reserved JS words like 'enum'

Josh Tynjala
We've already modified the compiler to support several AS3 reserved words
as identifier names. As I mentioned in my previous post, JavaScript started
allowing reserved words in places where they couldn't be used before with
ES5. Since AS3 is derived from ECMAScript, it's pretty safe for us to do
the same.

- Josh

On Tue, May 23, 2017 at 12:19 AM, Olaf Krueger <[hidden email]> wrote:

> >I guess the stream will definitely direct towards more people migrating to
> JS so I think we shouldn’t >prohibit flash related reserver words in the js
> world.
>
> I'm confused.
> Do you mean that we should allow using AS3 reserved words if they are
> allowed in the JS world?
> Wouldn't that mean that AS3 does not work fine at the end?
>
> Thanks,
> Olaf
>
>
>
>
> --
> View this message in context: http://apache-flex-
> development.2333347.n4.nabble.com/FlexJS-Compiler-doesn-t-
> recognize-reserved-JS-words-like-enum-tp61735p61762.html
> Sent from the Apache Flex Development mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [FlexJS] Compiler doesn't recognize reserved JS words like 'enum'

Olaf Krueger
Josh Tynjala wrote
 As I mentioned in my previous post, JavaScript started
allowing reserved words in places where they couldn't be used before with
ES5. Since AS3 is derived from ECMAScript, it's pretty safe for us to do
Hi Josh,
maybe I get something wrong once again or I miss something but for me, it seems that 'enum' is defined as a reserved keyword since ECMAScript1 and until ECMAScript6.
As you mentioned in ES5 a lot of these keywords were removed, but 'enum' is still there.
This is a nice overview of reserved words and different ES versions [1]

If you agree to teach the compiler that 'enum' should be recognised as reserved keyword I'd file a JIRA.
And maybe I could assign this JIRA to myself if the solution is not o complicated.
How could this be achieved? I found this which seems to me as a proper place to just add as3ReservedWords.add("enum"); [2]

Thanks,
Olaf

[1] https://mathiasbynens.be/notes/reserved-keywords
[1] https://github.com/apache/flex-falcon/blob/7137de6b19cd11630ee1ef29f7a9164166e35b10/flex-compiler-oem/src/main/java/flex2/compiler/mxml/lang/StandardDefs.java#L623


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [FlexJS] Compiler doesn't recognize reserved JS words like 'enum'

Josh Tynjala
In ES5, there were two changes. As you said, they removed some items from
the list of reserved words. Also, all reserved words are now allowed to be
used for certain names. As I recall, this includes names of members, but
not names of local variables. If enum is still considered reserved in ES,
then it probably can't be used as a function parameter, but it can be used
as a member variable or function name.

- Josh

On May 24, 2017 12:53 AM, "Olaf Krueger" <[hidden email]> wrote:

Josh Tynjala wrote
>  As I mentioned in my previous post, JavaScript started
> allowing reserved words in places where they couldn't be used before with
> ES5. Since AS3 is derived from ECMAScript, it's pretty safe for us to do

Hi Josh,
maybe I get something wrong once again or I miss something but for me, it
seems that 'enum' is defined as a reserved keyword since ECMAScript1 and
until ECMAScript6.
As you mentioned in ES5 a lot of these keywords were removed, but 'enum' is
still there.
This is a nice overview of reserved words and different ES versions [1]

If you agree to teach the compiler that 'enum' should be recognised as
reserved keyword I'd file a JIRA.
And maybe I could assign this JIRA to myself if the solution is not o
complicated.
How could this be achieved? I found this which seems to me as a proper place
to just add as3ReservedWords.add("enum"); [2]

Thanks,
Olaf

[1] https://mathiasbynens.be/notes/reserved-keywords
[1]
https://github.com/apache/flex-falcon/blob/7137de6b19cd11630
ee1ef29f7a9164166e35b10/flex-compiler-oem/src/main/java/
flex2/compiler/mxml/lang/StandardDefs.java#L623






--
View this message in context: http://apache-flex-development
.2333347.n4.nabble.com/FlexJS-Compiler-doesn-t-recognize-
reserved-JS-words-like-enum-tp61735p61832.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.
Loading...