Bug 188952 - output of toString() of Generator is wrong
Summary: output of toString() of Generator is wrong
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-08-26 00:30 PDT by sunlili
Modified: 2018-08-31 08:56 PDT (History)
8 users (show)

See Also:


Attachments
Patch (11.48 KB, patch)
2018-08-30 11:09 PDT, Yusuke Suzuki
saam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description sunlili 2018-08-26 00:30:00 PDT
Executing following code :
--------------------------------------
var f = function* () {}
print(f.toString());
--------------------------------------

Output of JavaScriptCore is :
function () {}

However, the output should be :
function* () {}

BT group
2018.08.26
Comment 1 Yusuke Suzuki 2018-08-30 11:09:56 PDT
Created attachment 348511 [details]
Patch
Comment 2 Saam Barati 2018-08-30 11:12:02 PDT
Comment on attachment 348511 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=348511&action=review

r=me

> Source/JavaScriptCore/runtime/FunctionPrototype.cpp:136
> +        case SourceParseMode::AsyncGeneratorWrapperMethodMode:

Shouldn't this async generator method be "async* " since that's the syntax?
Comment 3 Yusuke Suzuki 2018-08-30 12:04:13 PDT
Comment on attachment 348511 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=348511&action=review

Thanks!

>> Source/JavaScriptCore/runtime/FunctionPrototype.cpp:136
>> +        case SourceParseMode::AsyncGeneratorWrapperMethodMode:
> 
> Shouldn't this async generator method be "async* " since that's the syntax?

Right now, we always emit `async function* ...` even for async generator methods, as we emit `function xxx() { }` for methods.
When https://tc39.github.io/Function-prototype-toString-revision/ is integrated into JSC, we should revisit these cases.
Comment 4 Yusuke Suzuki 2018-08-30 12:06:27 PDT
Landed in https://trac.webkit.org/changeset/235514/webkit
Comment 5 Radar WebKit Bug Importer 2018-08-31 08:56:34 PDT
<rdar://problem/43941925>