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

[5.x] Fix null coalescence operator evaluation #11221

Conversation

godismyjudge95
Copy link
Contributor

@marcorieser Brought up in discord that the null coalescence operator is not functioning like you'd expect.

It is expected that if the left side of the operator is not null then the right side would never be evaluated.

This is a contrived example that showcases the behavior:

{{ hello = "Hello" }}
{{ world = "World" }}
{{ hello ?? (world = "Earth") }} {{ world }}

Based on the order of operations and evaluation order, you'd expect the above to output:

Hello World

But it instead outputs:

Hello Earth

Because the right side of the operator is evaluated regardless of the left side being nullish.

This PR adds a test and fixes that behavior.

@jasonvarga jasonvarga merged commit a0a385a into statamic:5.x Dec 5, 2024
18 checks passed
@godismyjudge95 godismyjudge95 deleted the fix-antlers-null-coalescence-evaluation branch December 5, 2024 19:42
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.

2 participants