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

Flag middle comma SEF operands #33648

Closed

Conversation

RyanCavanaugh
Copy link
Member

Fixes #33646

@RyanCavanaugh
Copy link
Member Author

@typescript-bot test this
@typescript-bot user test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 27, 2019

Heya @RyanCavanaugh, I've started to run the parallelized community code test suite on this PR at d851fd2. You can monitor the build here. It should now contribute to this PR's status checks.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 27, 2019

Heya @RyanCavanaugh, I've started to run the extended test suite on this PR at d851fd2. You can monitor the build here. It should now contribute to this PR's status checks.

@typescript-bot
Copy link
Collaborator

The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master.

// A comma operator is SEF if either operand is SEF, e.g. the template argument in
// `The coordinates are ${x.toString(), y, z}`
// contains an illegally SEF expression at 'y' (the left side of the outer comma whose right operand is 'z')
return isSideEffectFree((node as BinaryExpression).left) || isSideEffectFree((node as BinaryExpression).right);
Copy link
Member

Choose a reason for hiding this comment

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

So this is less isSideEffectFree and more containsSideEffectFree now, right? Since technically the comma operator itself would only actually be side-effect free if everything it executed was free of side effects?

Copy link
Member Author

@RyanCavanaugh RyanCavanaugh Sep 28, 2019

Choose a reason for hiding this comment

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

I don't think so. f() + 4 contains a non-side-effect-free expression, but is side-effect-free due to the addition operator itself not being something that can produce side effects*

Upon thinking about this more, I think the correct fix is just to return true if the operator in a binary expression isn't an assignment operator. The expression [(f(), 4, 2)] is equally wrong as [(f() + 4, 2)]; the comma is a red herring. I'll try this on Monday.

* let's continue to pretend valueOf doesn't exist, per convention

@sandersn
Copy link
Member

@RyanCavanaugh it looks like you were intending to simplify this PR. Do you want to try that or should I just close it since it's been quite a while?

@sandersn sandersn closed this Mar 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Backlog Bug PRs that fix a backlog bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Middle operand in comma operator list not properly checked for side-effect-freeness
4 participants