New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 835209 link

Starred by 4 users

Issue metadata

Status: WontFix
Owner:
Closed: Aug 16
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , Chrome , Mac
Pri: 2
Type: Bug



Sign in to add a comment

anonymous functions split over two lines

Reported by somewher...@gmail.com, Apr 20 2018

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36

Example URL:

Steps to reproduce the problem:
1. Create new Function in JavaScript using new Function()
2. 
3. 

What is the expected behavior?
This will create an anonymous function similar to 

Function anonymous() {
}

What went wrong?
Since upgrading to version 66 of Chrome this now splits the function across two lines. Previous versions work correctly and all other browsers work correctly.

Function anonymous(
) {

instead of 

Function anonymous() {

Does it occur on multiple sites: Yes

Is it a problem with a plugin? No 

Did this work before? N/A 

Does this work in other browsers? Yes

Chrome version: 66.0.3359.117  Channel: stable
OS Version: 10.0
Flash Version: 

We have .replace() code specifically looking for .replace('function anonymous() {', '') which no longer works since upgrading to version 66 of Chrome
 

Comment 1 by woxxom@gmail.com, Apr 20 2018

Bisected to acad4277ed3135b2aede8d62c20266688962e89f "Update V8 to version 6.5.170."
Specifically 6fe75e30aacff1f2e9b10a01e20bebd68fe56474 "Reland: Enable --harmony-function-tostring by default"

    For functions created with the Function, GeneratorFunction, or
    AsyncFunction constructors:
    * The string separating the parameter text and body text is now
      "\n) {\n", where previously it was "\n/*``*/) {\n" or ") {\n".

Looks like the change is intended and matches the updated specification.
You can switch to a regex: .replace(/^function\s+anonymous\(\s*\)\s*\{/, '')
Or even a 2-in-1 regex: .replace(/^function\s+anonymous\(\s*\)\s*\{\s*|\s*\}$/g, '')
But this breaks all existing platforms with customers and has prevented use of our software! We are now having to advise customers to use IE instead as it doesn't have the same issue. We are aware of how to counteract the change. But this change doesnt seem logical?

Comment 3 by woxxom@gmail.com, Apr 21 2018

Quoting the new specification:
http://tc39.github.io/Function-prototype-toString-revision/#proposal-sec-createdynamicfunction

    39. Let sourceText be the String value whose elements are, in order, the code units of prefix, 
        the code units of " anonymous(", the code units of P, 0x000A (LINE FEED), the code units of ") {", 
        0x000A (LINE FEED), the code units of bodyText, 0x000A (LINE FEED), and the code units of "}".

As you can see Chrome matches the specification. It's still Stage 3 draft, though.
FWIW, to disable the feature you can add --js-flags=--noharmony-function-tostring to the chrome's shortcut command line.
Cc: vamshi.kommuri@chromium.org adamk@chromium.org
Components: -Blink Blink>JavaScript
Labels: Needs-Feedback Triaged-ET
Thanks for filing the issue!

@Reporter: Could you please share a sample test file which helps us to triage the issue in a better way. Any further inputs from your end may be helpful.

And as per comment #1 cc'ing @adamk for more inputs on this issue.
Labels: Needs-Triage-M66
Cc: jwo...@igalia.com littledan@chromium.org
Owner: gsat...@chromium.org
Components: -Blink>JavaScript Blink>JavaScript>Language
Labels: -Arch-x86_64 -Via-Wizard-Content -Triaged-ET -Needs-Triage-M66 OS-Android OS-Chrome OS-Linux OS-Mac
Status: Assigned (was: Unconfirmed)
Oh, looks like this fell through the cracks.

As #3 points out, this is per the new spec. Are you still facing breakage or has this been fixed on your end? Firefox is now shipping this behavior as well, so we'd like to know sooner than later if this is still breaking.
What's the current thought on this issue? Should we bring it up again at the next TC39 meeting for discussion?
Status: WontFix (was: Assigned)
Closing as WontFix as this is the specced behavior.

Sign in to add a comment