Skip to content
This repository was archived by the owner on Jan 25, 2022. It is now read-only.
This repository was archived by the owner on Jan 25, 2022. It is now read-only.

toString result in CreateDynamicFunction doesn't match to existing implementations #20

@arai-a

Description

@arai-a

With the proposal, Function("a", "b", "c").toString() generates the following string:

function anonymous(a,b
) {c
}

but it doesn't match to existing implementations.

Firefox

function anonymous(a, b) {
c
}

Chrome

function anonymous(a,b
/**/) {
c
}

Safari

function anonymous(a, b) {
c
}

Edge

function anonymous(a,b) {
c
}

So, the main differences are:

  • LF before body is removed in the proposal
  • LF after parameters is added in the proposal, except Chrome

Question 1.
Is there any good reason to remove LF before body?
putting LF there should give us better string representation, and matches to existing implementations.

Question 2.
About LF after parameters, If I understand correctly, it's there to make toString result not SyntaxError when parameter contains "//". But it's necessary only in the case.
How about putting LF only if necessary? (it will introduce additional complexity tho...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions