-
-
Notifications
You must be signed in to change notification settings - Fork 755
fix(ast/estree): fix Function.this_param
#9913
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(ast/estree): fix Function.this_param
#9913
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Instrumentation Performance ReportMerging #9913 will not alter performanceComparing Summary
|
431392e to
7936dae
Compare
overlookmotel
left a comment
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.
I think there's a better way than adding SequenceSerializer::serialize_ts_element. I'll make a follow-up PR.
But... test passes % into double figures! Still a long way to go, but we're getting somewhere now...
Merge activity
|
20f19af to
ae3a901
Compare
`Function.this_param` is included in `Function.params` as an `Identifier` with `name: "this"` https://ast-explorer.dev/#eNolykEKwzAMRNGrmFm10F7AB+lKG2MU6uAoJlICwfjuUchiNu9PR0XEnI6keSvN8EFzsLPxA1/WWuT27D7tkq2sEqaX/YvG0Mfb53X12klCIHBe0o839R8hOtRkrEYgGRgXircmAw==
ae3a901 to
8228b74
Compare
Follow-on after #9913. `TSThisParameter` is a TS-only type, so its fields aren't optional the way the TS fields of JS types are. Fix the type def by using JS versions of added fields (`False` instead of `TsFalse` etc). Also re-order the fields, so that `name` is first. We want the object shape to be the same (same field order) for all types which are `Identifier`s in the ESTree AST.
…zer` (#9943) Remove the `serialize_ts_element` method added in #9913, and instead expose an `INCLUDE_TS_FIELDS` constant on `Serializer` trait. Before: ```rs if let Some(this_param) = &self.0.this_param { seq.serialize_ts_element(this_param); } ``` After: ```rs if S::INCLUDE_TS_FIELDS { if let Some(this_param) = &self.0.this_param { seq.serialize_element(this_param); } } ``` This has one slight advantage. Because `INCLUDE_TS_FIELDS` is a constant, compiler will easily be able to prove that the code inside `if S::INCLUDE_TS_FIELDS { ... }` is dead code in the JS-only AST serializer, and remove it. In this specific case, the TS-only logic is trivial, so compiler would probably see it could be optimized out anyway. But we may encounter other cases where more complex TS-only code is required, and compiler might not be able to prove that it's dead code in those cases.

Function.this_paramis included inFunction.paramsas anIdentifierwithname: "this"https://ast-explorer.dev/#eNolykEKwzAMRNGrmFm10F7AB+lKG2MU6uAoJlICwfjuUchiNu9PR0XEnI6keSvN8EFzsLPxA1/WWuT27D7tkq2sEqaX/YvG0Mfb53X12klCIHBe0o839R8hOtRkrEYgGRgXircmAw==