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

test(transformer/class-properties): more testing for assignment to super[prop] #7992

Conversation

overlookmotel
Copy link
Contributor

@overlookmotel overlookmotel commented Dec 18, 2024

Amend test added in #7991 to test transform of super[prop] = value where prop is not bound.

We should ideally have the _unbound temp vars inside the arrow function rather than outside, as Babel does, but that's not possible with our double-visitor scheme at present, and I think current output will operate correctly anyway.

Probably these temp vars could be hoisted even higher up - to very top level of the file, even if the class and super[prop] were deeply nested in many functions - and it'd still be correct. That'd be good for transformer performance as less var statements to insert, and also slightly smaller output size - less vars in code. But I don't know if that would be worse for runtime performance, as it makes the arrow function more impure. 🤔

Copy link
Contributor Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

@github-actions github-actions bot added A-transformer Area - Transformer / Transpiler C-test Category - Testing. Code is missing test cases, or a PR is adding them labels Dec 18, 2024
@overlookmotel overlookmotel marked this pull request as ready for review December 18, 2024 11:41
@overlookmotel
Copy link
Contributor Author

overlookmotel commented Dec 18, 2024

Just a thought for the future...

We could also reduce size of output by adding more helpers.

e.g.:

  • super.prop += 123 -> _superPropAdd(_Class, "prop", 123)
  • super.prop -= 123 -> _superPropMinus(_Class, "prop", 123)
  • super.prop &&= 123 -> _superPropAnd(_Class, "prop", 123)
  • etc

Then no temp vars required at all.

Same thing for lots of other transforms which currently produce very long output.

foo() ?? bar() -> _isNullOrUndefined(_foo = foo()) ? bar() : _foo or _coalesce(foo(), () => bar())

@Dunqing
Copy link
Member

Dunqing commented Dec 18, 2024

Just a thought for the future...

We could also reduce size of output by adding more helpers.

e.g.:

  • super.prop += 123 -> _superPropAdd(_Class, "prop", 123)
  • super.prop -= 123 -> _superPropMinus(_Class, "prop", 123)
  • super.prop &&= 123 -> _superPropAnd(_Class, "prop", 123)
  • etc

Then no temp vars required at all.

Same thing for lots of other transforms which currently produce very long output.

foo() ?? bar() -> _isNullOrUndefined(_foo = foo()) ? bar() : _foo or _coalesce(foo(), () => bar())

Yes, this is a good direction to reduce size of the transformation output

@Dunqing Dunqing added the 0-merge Merge with Graphite Merge Queue label Dec 18, 2024
Copy link
Member

Dunqing commented Dec 18, 2024

Merge activity

  • Dec 18, 7:49 AM EST: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Dec 18, 7:49 AM EST: A user added this pull request to the Graphite merge queue.
  • Dec 18, 7:53 AM EST: A user merged this pull request with the Graphite merge queue.

…uper[prop]` (#7992)

Amend test added in #7991 to test transform of `super[prop] = value` where `prop` is not bound.

We should ideally have the `_unbound` temp vars *inside* the arrow function rather than outside, as Babel does, but that's not possible with our double-visitor scheme at present, and I think current output will operate correctly anyway.

Probably these temp vars could be hoisted even higher up - to very top level of the file, even if the class and `super[prop]` were deeply nested in many functions - and it'd still be correct. That'd be good for transformer performance as less `var` statements to insert, and also slightly smaller output size - less `var`s in code. But I don't know if that would be worse for runtime performance, as it makes the arrow function more impure. 🤔
@Dunqing Dunqing force-pushed the 12-18-test_transformer_class-properties_more_testing_for_assignment_to_super_prop_ branch from e9af5ee to 5cf253c Compare December 18, 2024 12:49
@graphite-app graphite-app bot merged commit 5cf253c into main Dec 18, 2024
15 checks passed
@graphite-app graphite-app bot deleted the 12-18-test_transformer_class-properties_more_testing_for_assignment_to_super_prop_ branch December 18, 2024 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0-merge Merge with Graphite Merge Queue A-transformer Area - Transformer / Transpiler C-test Category - Testing. Code is missing test cases, or a PR is adding them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants