Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Reproduce issue #426#427

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
lucivpav wants to merge1 commit intoestools:master
base:master
Choose a base branch
Loading
fromlucivpav:bug-426
Draft

Conversation

@lucivpav
Copy link

@lucivpavlucivpav commentedOct 7, 2020
edited
Loading

Reproduces#426

@Meir017
Copy link

@lucivpav I just ran into this issue too.
I found a solution for this -

escodegen/escodegen.js

Lines 946 to 949 inab53cd5

expr=this.generateExpression(node.body,Precedence.Assignment,E_TTT);
if(expr.toString().charAt(0)==='{'){
expr=['(',expr,')'];
}

this should be

varstrExpr=expr.toString();if(strExpr[0]==='{'||strExpr[strExpr.length-1]==='}'){expr=['(',expr,')'];}

I'm pretty sure the last character cannot be part of the comment, in that case the comment would not be part of the node

@lucivpav
Copy link
Author

I wonder if this fix works for the affected parenthesized expressions in general, or just in function bodies 🤔

@Meir017
Copy link

@lucivpav a better solution is to check the node types:

if(node.type===Syntax.ArrowFunctionExpression&&node.body.type===Syntax.ObjectExpression){expr=['(',expr,')'];}

@Itazulay
Copy link

@lucivpav This PR does not cover this scenario:
var a = b => ({}.hasOwnProperty.call(b, "c"));
This is a CallExpression and not an ObjectExpression.
Maybe it should be simply:
if (node.type === Syntax.ArrowFunctionExpression) { expr = ['(', expr, ')']; }

@lucivpav
Copy link
Author

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@lucivpav@Meir017@Itazulay

[8]ページ先頭

©2009-2025 Movatter.jp