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

PHP 7.4 fn closure invalid scope closer with ternary #2715

Closed
michalbundyra opened this issue Nov 19, 2019 · 1 comment
Closed

PHP 7.4 fn closure invalid scope closer with ternary #2715

michalbundyra opened this issue Nov 19, 2019 · 1 comment
Milestone

Comments

@michalbundyra
Copy link
Contributor

Example:

<?php

$fn = fn ($a) => $a ? fn () : string => 'a' : fn () : string => 'b';

var_dump($fn(0)()); // string(a)
var_dump($fn(1)()); // string(b)

so what we should have here is:

  • ✅ scope_closer for first fn should be the final ;
  • ❌ scope_closer for "then" fn should be : (else) - it is the final ; instead
  • ✅ scope_close for "else" fn should be the final ;

Related to #2523

@gsherwood gsherwood added this to the 3.5.3 milestone Nov 20, 2019
@gsherwood
Copy link
Member

I've pushed a fix for this case. I'm not super happy with the code, but I feel like there are going to be a few more cases like this, so I can refactor later. At least there are tests cases for it.

Thanks a lot for reporting this.

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

No branches or pull requests

2 participants