-
-
Notifications
You must be signed in to change notification settings - Fork 485
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
fix(semantic): consider update expressions in implicit returns as reads #5158
fix(semantic): consider update expressions in implicit returns as reads #5158
Conversation
Your org has enabled the Graphite merge queue for merging into mainAdd the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix. You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link. |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
c9f7308
to
70f30e6
Compare
CodSpeed Performance ReportMerging #5158 will not alter performanceComparing Summary
|
70f30e6
to
20ebc2e
Compare
let in_return = self.is_in_return; | ||
self.is_in_return = true; | ||
self.visit_expression(arg); | ||
self.is_in_return = in_return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may cause a bit of difficulty in maintaining. We should avoid writing any logic in the visit function.
@Dunqing I'll split the linter test cases into a separate PR, I think I accidentally committed them... there's a few test cases missing in this PR, which I've left as comments in yours. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is quite hard to give an opinion on. Personally I don't understand why i++
/ ++i
isn't always considered Read | Write
(#3326), so I don't know what the meaning of the Read
flag is currently.
But, putting that aside for a minute and assuming that your logic is correct... in terms of implementation, is it not possible to use current_reference_flags
for this, rather than introducing a new is_in_return
property?
SemanticTester::js("let i = 0; const x = () => (++i, 0)") | ||
.has_root_symbol("i") | ||
.has_number_of_reads(1) | ||
.has_number_of_writes(1) | ||
.test(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this test correct? I don't think i
is being read from here (but see my general comment - I'm not sure).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, I am not sure what i
ReferenceFlags should be. The x
function return result is 0 when it is called, so i
should be write
only. I think we can try to make i
only contain write
if no tests are broken
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try to get to the bottom of it! #5165
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it's not, but there are other test cases that enforce this behavior. I mentioned this to you (@Dunqing) a while ago, when you made that change, and your rationale was that "we don't know what's a read and what's not a read, since things could be proxies and/or getters/setters"
Oh, I now see Dunqing has taken exactly this approach in #5161... |
20ebc2e
to
811440b
Compare
8833061
to
d29042e
Compare
811440b
to
5a4faf1
Compare
Closes #5156