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

Feature: Add support for spread operator #54

Merged
merged 1 commit into from
Nov 20, 2024
Merged

Feature: Add support for spread operator #54

merged 1 commit into from
Nov 20, 2024

Conversation

zackad
Copy link
Owner

@zackad zackad commented Aug 16, 2024

Close GH-44.

Partially depends on GH-16.

Need help on how to parse this expression

Error: Error: ERROR: Invalid map key
  32 | <twig:Component {{ ...vars }} />
  33 | {% set numbers = [1, 2, ...moreNumbers] %}
> 34 | {% set ratings = {'foo': 10, 'bar': 5, ...moreRatings} %}
     |                                        ^
  35 | 

@zackad
Copy link
Owner Author

zackad commented Oct 5, 2024

Example of spread operator usage from twig documentation.

{% set numbers = [1, 2, ...moreNumbers] %}
{% set ratings = {'q1': 10, 'q2': 5, ...moreRatings} %}

{{ 'Hello %s %s!'|format(...['Fabien', 'Potencier']) }}

Ref: https://twig.symfony.com/doc/3.x/templates.html

@zackad zackad changed the title [WIP] Feature: Add support for spread operator Feature: Add support for spread operator Nov 16, 2024
@zackad zackad marked this pull request as ready for review November 16, 2024 01:56
src/print/UnarySubclass.js Outdated Show resolved Hide resolved
@zackad zackad requested a review from rellafella November 16, 2024 02:01
Copy link
Collaborator

@rellafella rellafella left a comment

Choose a reason for hiding this comment

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

LGTM
I have just left the comment there about the precedence of the spread operator. My understanding is that as long as the precedence score is lower than that of the range operator .. (25), it should be fine.

src/melody/melody-extension-core/operators.js Outdated Show resolved Hide resolved
@zackad zackad merged commit 5b1399a into master Nov 20, 2024
3 checks passed
@zackad zackad deleted the spread-operator branch November 20, 2024 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for spread operator
2 participants