Bug 212679 - Logical Assignment: perform NamedEvaluation of anonymous functions
Summary: Logical Assignment: perform NamedEvaluation of anonymous functions
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Devin Rousso
URL:
Keywords: InRadar
Depends on: 209716
Blocks:
  Show dependency treegraph
 
Reported: 2020-06-02 18:52 PDT by Devin Rousso
Modified: 2020-06-05 12:08 PDT (History)
11 users (show)

See Also:


Attachments
Patch (1.93 KB, patch)
2020-06-02 19:33 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (4.86 KB, patch)
2020-06-05 10:39 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Devin Rousso 2020-06-02 18:52:33 PDT
```
    let foo = null;
    foo ??= function() {};
    console.log(foo.name); // should be "foo", but is currently ""
```
which matches the functionality of regular assignments
```
    let foo = function() {};
    console.log(foo.name); // "foo"
```

Issue: <https://github.com/tc39/proposal-logical-assignment/issues/23>
PR: <https://github.com/tc39/proposal-logical-assignment/pull/24>
Comment 1 Devin Rousso 2020-06-02 19:33:20 PDT
Created attachment 400884 [details]
Patch
Comment 2 Ross Kirsling 2020-06-02 19:58:48 PDT
Comment on attachment 400884 [details]
Patch

r=me as long as the test262 update is incoming.
Comment 3 Joseph Pecoraro 2020-06-03 01:12:17 PDT
Nice. Yeah there should be some test associated with this!
Comment 4 Devin Rousso 2020-06-04 15:24:20 PDT
I manually tested the test262 updates in <https://github.com/tc39/test262/pull/2649> and we passed them all :)

@yusukesuzuki suggested that I land this rather than wait for the tests so we can get additional fuzzing coverage.

I'm inclined to agree, especially with how simple this change is and the fact that we already pass the tests.

Thoughts?
Comment 5 Saam Barati 2020-06-04 15:36:00 PDT
(In reply to Devin Rousso from comment #4)
> I manually tested the test262 updates in
> <https://github.com/tc39/test262/pull/2649> and we passed them all :)
> 
> @yusukesuzuki suggested that I land this rather than wait for the tests so
> we can get additional fuzzing coverage.
> 
> I'm inclined to agree, especially with how simple this change is and the
> fact that we already pass the tests.
> 
> Thoughts?

Why not just write your own test?
Comment 6 Devin Rousso 2020-06-04 16:35:12 PDT
(In reply to Saam Barati from comment #5)
> (In reply to Devin Rousso from comment #4)
> > I manually tested the test262 updates in <https://github.com/tc39/test262/pull/2649> and we passed them all :)
> > 
> > @yusukesuzuki suggested that I land this rather than wait for the tests so we can get additional fuzzing coverage.
> > 
> > I'm inclined to agree, especially with how simple this change is and the fact that we already pass the tests.
> > 
> > Thoughts?
> 
> Why not just write your own test?

I could, but I would write basically the exact same tests, so I thought it was duplicate effort for no reward (same code being tested twice).
Comment 7 Saam Barati 2020-06-04 16:36:03 PDT
(In reply to Devin Rousso from comment #6)
> (In reply to Saam Barati from comment #5)
> > (In reply to Devin Rousso from comment #4)
> > > I manually tested the test262 updates in <https://github.com/tc39/test262/pull/2649> and we passed them all :)
> > > 
> > > @yusukesuzuki suggested that I land this rather than wait for the tests so we can get additional fuzzing coverage.
> > > 
> > > I'm inclined to agree, especially with how simple this change is and the fact that we already pass the tests.
> > > 
> > > Thoughts?
> > 
> > Why not just write your own test?
> 
> I could, but I would write basically the exact same tests, so I thought it
> was duplicate effort for no reward (same code being tested twice).

it's helpful to have tests that live outside test262
Comment 8 Yusuke Suzuki 2020-06-04 17:35:39 PDT
(In reply to Devin Rousso from comment #6)
> (In reply to Saam Barati from comment #5)
> > (In reply to Devin Rousso from comment #4)
> > > I manually tested the test262 updates in <https://github.com/tc39/test262/pull/2649> and we passed them all :)
> > > 
> > > @yusukesuzuki suggested that I land this rather than wait for the tests so we can get additional fuzzing coverage.
> > > 
> > > I'm inclined to agree, especially with how simple this change is and the fact that we already pass the tests.
> > > 
> > > Thoughts?
> > 
> > Why not just write your own test?
> 
> I could, but I would write basically the exact same tests, so I thought it
> was duplicate effort for no reward (same code being tested twice).

I like adding these tests into JSTests/stress/ even if test262 has duplicate ones.
test262 is shared with other engines. Due to some mistakes in test262, the coverage in JSC can be regressed.
One example is this[1]. test262 putted BigInt to utility file and every tests using this utility file failed in JSC even if the test is not using BigInt.

I'm seeing very similar issues in WPT, and I think dedicated JSC stress tests is better in terms of regression testing.

[1]: https://github.com/tc39/test262/issues/1252
Comment 9 Devin Rousso 2020-06-05 10:39:20 PDT
Created attachment 401174 [details]
Patch

Thanks for the feedback @saamyjoon and @yusukesuzuki, I had not considered test262 itself having issues.  I've added some test cases to JSTests/stress/logical-assignment-{aoperator-nd,coalesce,or}.js :)
Comment 10 EWS 2020-06-05 12:06:09 PDT
Committed r262638: <https://trac.webkit.org/changeset/262638>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 401174 [details].
Comment 11 Radar WebKit Bug Importer 2020-06-05 12:08:05 PDT
<rdar://problem/64039177>