RE: Bug in extractVarNodesFromDeadCode. Variable "x" has already been declared

2020-12-15 Thread ?????????? ????? ?????????
Hi.

Since Nashorn is in development again, perhaps this bug
(https://bugs.openjdk.java.net/browse/JDK-8233195) can be fixed instead of
"Won't Fix" resolution?

-Original Message-
From: nashorn-dev [mailto:nashorn-dev-boun...@openjdk.java.net] On Behalf Of
Hannes Wallnofer
Sent: Wednesday, October 30, 2019 1:31 PM
To: Nashorn-Dev
Subject: Re: Bug in extractVarNodesFromDeadCode. Variable "x" has already
been declared

Thanks for the report!

https://bugs.openjdk.java.net/browse/JDK-8233195

The provided patch looks reasonable so the chances to get this fixed are
quite good.

Hannes


> Am 28.10.2019 um 16:47 schrieb Jim Laskey :
> 
> Obviously, this wasn't intended for the list. To clarify, since Nashorn is
being deprecated, we are taking input such as this and recording it as a bug
in case someone adopts Nashorn in future.
> 
> Cheers,
> 
> -- Jim
> 
> 
>> On Oct 28, 2019, at 12:36 PM, Jim Laskey  wrote:
>> 
>> You want to take this on?  File a bug and put the e-mail (change set) in
it, then tell the user Nashorn is deprecated.
>> 
>>> On Oct 28, 2019, at 12:21 PM, Anton Mitrofanov 
wrote:
>>> 
>>> Hi.
>>> 
>>> We have encountered another bug in Nashorn. It can be reproduced by
evaluation of this script with "jjs --language=es6":
>>> 
>>> if (true) { throw "test"; } { let x = "1"; } { let x = 2; }
>>> 
>>> It results in compilation error:
>>> 
>>> ECMAScript Exception: SyntaxError: :1:34 Variable "x" has already
been declared if (true) { throw "test"; } { let x = "1"; } { let x = 2; }
>>>^
>>> While expected out was to get runtime exception "test".
>>> 
>>> Looks like the problem is in dead code elimination logic of
FoldConstants.extractVarNodesFromDeadCode function.
>>> 
>>> And here is the patch to fix it:
>>> 
>>> diff -r 6e287efa5fa3
src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FoldCon
stants.java
>>> ---
a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FoldC
onstants.java   Wed Oct 23 09:53:07 2019 +0200
>>> +++
b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FoldC
onstants.java   Wed Oct 23 14:23:48 2019 +0300
>>> @@ -195,7 +195,9 @@
>>>   deadCodeRoot.accept(new SimpleNodeVisitor() {
>>>   @Override
>>>   public boolean enterVarNode(final VarNode varNode) {
>>> -statements.add(varNode.setInit(null));
>>> +if (!varNode.isBlockScoped()) {
>>> +statements.add(varNode.setInit(null));
>>> +}
>>>   return false;
>>>   }
>>> 
>>> 
>> 
> 




Re: Bug in extractVarNodesFromDeadCode. Variable "x" has already been declared

2019-10-30 Thread Matt Zand
 Hey guys,

How I can un-subscribe from this mailing list

Thx,

On Wed, Oct 30, 2019 at 6:33 AM Hannes Wallnöfer <
hannes.wallnoe...@oracle.com> wrote:

> Thanks for the report!
>
> https://bugs.openjdk.java.net/browse/JDK-8233195
>
> The provided patch looks reasonable so the chances to get this fixed are
> quite good.
>
> Hannes
>
>
> > Am 28.10.2019 um 16:47 schrieb Jim Laskey :
> >
> > Obviously, this wasn't intended for the list. To clarify, since Nashorn
> is being deprecated, we are taking input such as this and recording it as a
> bug in case someone adopts Nashorn in future.
> >
> > Cheers,
> >
> > -- Jim
> >
> >
> >> On Oct 28, 2019, at 12:36 PM, Jim Laskey 
> wrote:
> >>
> >> You want to take this on?  File a bug and put the e-mail (change set)
> in it, then tell the user Nashorn is deprecated.
> >>
> >>> On Oct 28, 2019, at 12:21 PM, Anton Mitrofanov 
> wrote:
> >>>
> >>> Hi.
> >>>
> >>> We have encountered another bug in Nashorn. It can be reproduced by
> evaluation of this script with "jjs --language=es6":
> >>>
> >>> if (true) { throw "test"; } { let x = "1"; } { let x = 2; }
> >>>
> >>> It results in compilation error:
> >>>
> >>> ECMAScript Exception: SyntaxError: :1:34 Variable "x" has
> already been declared if (true) { throw "test"; } { let x = "1"; } { let x
> = 2; }
> >>>^
> >>> While expected out was to get runtime exception "test".
> >>>
> >>> Looks like the problem is in dead code elimination logic of
> FoldConstants.extractVarNodesFromDeadCode function.
> >>>
> >>> And here is the patch to fix it:
> >>>
> >>> diff -r 6e287efa5fa3
> src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FoldConstants.java
> >>> ---
> a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FoldConstants.java
>  Wed Oct 23 09:53:07 2019 +0200
> >>> +++
> b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FoldConstants.java
>  Wed Oct 23 14:23:48 2019 +0300
> >>> @@ -195,7 +195,9 @@
> >>>   deadCodeRoot.accept(new SimpleNodeVisitor() {
> >>>   @Override
> >>>   public boolean enterVarNode(final VarNode varNode) {
> >>> -statements.add(varNode.setInit(null));
> >>> +if (!varNode.isBlockScoped()) {
> >>> +statements.add(varNode.setInit(null));
> >>> +}
> >>>   return false;
> >>>   }
> >>>
> >>>
> >>
> >
>
>

-- 
Cheers,

Matt Zand
Cell: 202-420-9192
Work: 240-200-6131
High School Technology Services 
DC Web Makers 
Coding Bootcamps 


Re: Bug in extractVarNodesFromDeadCode. Variable "x" has already been declared

2019-10-28 Thread Jim Laskey
Obviously, this wasn't intended for the list. To clarify, since Nashorn is 
being deprecated, we are taking input such as this and recording it as a bug in 
case someone adopts Nashorn in future.

Cheers,

-- Jim


> On Oct 28, 2019, at 12:36 PM, Jim Laskey  wrote:
> 
> You want to take this on?  File a bug and put the e-mail (change set) in it, 
> then tell the user Nashorn is deprecated.
> 
>> On Oct 28, 2019, at 12:21 PM, Anton Mitrofanov  wrote:
>> 
>> Hi.
>> 
>> We have encountered another bug in Nashorn. It can be reproduced by 
>> evaluation of this script with "jjs --language=es6":
>> 
>> if (true) { throw "test"; } { let x = "1"; } { let x = 2; }
>> 
>> It results in compilation error:
>> 
>> ECMAScript Exception: SyntaxError: :1:34 Variable "x" has already 
>> been declared if (true) { throw "test"; } { let x = "1"; } { let x = 2; }
>> ^
>> While expected out was to get runtime exception "test".
>> 
>> Looks like the problem is in dead code elimination logic of 
>> FoldConstants.extractVarNodesFromDeadCode function.
>> 
>> And here is the patch to fix it:
>> 
>> diff -r 6e287efa5fa3 
>> src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FoldConstants.java
>> --- 
>> a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FoldConstants.java
>> Wed Oct 23 09:53:07 2019 +0200
>> +++ 
>> b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FoldConstants.java
>> Wed Oct 23 14:23:48 2019 +0300
>> @@ -195,7 +195,9 @@
>>deadCodeRoot.accept(new SimpleNodeVisitor() {
>>@Override
>>public boolean enterVarNode(final VarNode varNode) {
>> -statements.add(varNode.setInit(null));
>> +if (!varNode.isBlockScoped()) {
>> +statements.add(varNode.setInit(null));
>> +}
>>return false;
>>}
>> 
>> 
> 



Re: Bug in extractVarNodesFromDeadCode. Variable "x" has already been declared

2019-10-28 Thread Jim Laskey
You want to take this on?  File a bug and put the e-mail (change set) in it, 
then tell the user Nashorn is deprecated.

> On Oct 28, 2019, at 12:21 PM, Anton Mitrofanov  wrote:
> 
> Hi.
> 
> We have encountered another bug in Nashorn. It can be reproduced by 
> evaluation of this script with "jjs --language=es6":
> 
> if (true) { throw "test"; } { let x = "1"; } { let x = 2; }
> 
> It results in compilation error:
> 
> ECMAScript Exception: SyntaxError: :1:34 Variable "x" has already been 
> declared if (true) { throw "test"; } { let x = "1"; } { let x = 2; }
>  ^
> While expected out was to get runtime exception "test".
> 
> Looks like the problem is in dead code elimination logic of 
> FoldConstants.extractVarNodesFromDeadCode function.
> 
> And here is the patch to fix it:
> 
> diff -r 6e287efa5fa3 
> src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FoldConstants.java
> --- 
> a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FoldConstants.java
>  Wed Oct 23 09:53:07 2019 +0200
> +++ 
> b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FoldConstants.java
>  Wed Oct 23 14:23:48 2019 +0300
> @@ -195,7 +195,9 @@
> deadCodeRoot.accept(new SimpleNodeVisitor() {
> @Override
> public boolean enterVarNode(final VarNode varNode) {
> -statements.add(varNode.setInit(null));
> +if (!varNode.isBlockScoped()) {
> +statements.add(varNode.setInit(null));
> +}
> return false;
> }
> 
>