Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Function.prototype.toString as per the latest specification #1520

Merged
merged 9 commits into from
Jul 17, 2024
Merged

Fixed Function.prototype.toString as per the latest specification #1520

merged 9 commits into from
Jul 17, 2024

Conversation

tuchida
Copy link
Contributor

@tuchida tuchida commented Jul 14, 2024

ref. #1188
Spec. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString#getting_source_text_of_a_function

(function() { /* comment */ if(1){}}).toString()

Expect

function() { /* comment */ if(1){}}

But

function () {
    if (1) {
    }
}

To fixed this, Decompiler has been removed.

@p-bakker
Copy link
Collaborator

Any idea if it covers all function .toString() variations mentioned in #1300?

@p-bakker
Copy link
Collaborator

@gbrail in #1188 (comment) you mentioned that you'd like to have backwards compatibility

Using GitHub's improved codesearch, I looked for Java files containing an import of the Decompiler and a call to the decompile function: https://github.com/search?q=org.mozilla.javascript.Decompiler+AND+decompile%28+language%3AJava&type=code&l=Java

This yields only a few results, most either of clones of Rhino or deprecated/abandoned projects (vjet, dltk) or projects that haven't had updates for years.

I'd say we bite the bullet and remove the Decompiler completely, even if this will go into 1.7.xx


package org.mozilla.javascript;

public enum DecompilerFlag {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to call this DecompilerFlag if there's no decompiling going on anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any good names?

@p-bakker
Copy link
Collaborator

@tuchida Maybe I'm overlooking something or you did it on purpose, but it looks to me that the Decompiler class hasn't been removed

@tuchida
Copy link
Contributor Author

tuchida commented Jul 15, 2024

@p-bakker Thanks! I removed. ref. bff0cd1

Any idea if it covers all function .toString() variations mentioned in #1300?

Some minor modifications may be necessary to support all Function.prototype.toString. I would like to separate Pull Requests. ref. #1300 (comment)

@gbrail
Copy link
Collaborator

gbrail commented Jul 15, 2024

I'm fine with removing Decompiler -- we have a bunch of other big changes with this release and if we have to say, "instead of Decompiler, use toString()" then I think we will be OK.

@gbrail
Copy link
Collaborator

gbrail commented Jul 15, 2024

Other than that, I see that this PR changes a lot of legacy test suites because the output changed. I had a quick look and I'm prett sure that none of the output changes are significant, so changing those test suites is OK with me, especially because we enable a bunch of test262 suite tests.

Are you fairly confident that these changes are benign?

Finally, you have two big changes to IRFactory in the queue. git will probably handle them OK but there's no guarantee, especially since the other one has a bunch of places where you wrap things with braces and change the indent level. Do you have a preference as to which one gets merged first?

@tuchida
Copy link
Contributor Author

tuchida commented Jul 16, 2024

Are you fairly confident that these changes are benign?

In terms of being on spec, Yes. I do not know the impact of breaking changes.

Do you have a preference as to which one gets merged first?

No, either is fine.

@gbrail
Copy link
Collaborator

gbrail commented Jul 17, 2024

Thanks for working on this -- I agree it's a good PR. Now that I merged your other one, this one needs conficlit resolution, so can you please do that and push a new commit? Thanks!

@tuchida
Copy link
Contributor Author

tuchida commented Jul 17, 2024

@gbrail Thanks! I resolved the conflicts.

@gbrail
Copy link
Collaborator

gbrail commented Jul 17, 2024

Thanks for doing this!

@gbrail gbrail merged commit 5bdd291 into mozilla:master Jul 17, 2024
3 checks passed
@rbri
Copy link
Collaborator

rbri commented Jul 18, 2024

@tuchida fantastic!!!! ❤️

Now i can remove my hack from the HtmlUnit fork of rhino. Thanks a lot.... hope to see more of you work gets merged soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support ES2019 Function.toString() revision
4 participants