-
Notifications
You must be signed in to change notification settings - Fork 677
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
Error with array references in Reconciler #8289
Comments
I found these snippets: https://psalm.dev/r/03af5df16f<?php
$a = 'a';
$b = false;
$doesNotMatter = ['a' => ['id' => 1]];
// only the reference `&` seems to matter here
// check PHP error message in XHR response
// ```
// Warning: Undefined array key "$doesNotMatter[$a]" in /var/www/vhosts/psalm.dev/httpdocs/vendor/vimeo/psalm/src/Psalm/Type/Reconciler.php on line 128
// {"error":{"message":"\/vendor\/vimeo\/psalm\/src\/Psalm\/Type\/Reconciler.php: __clone method called on non-object","line_from":128,"type":"psalm_error"}}
// ```
$reference = &$doesNotMatter[$a];
// this comparison is also involved
// interesting that `$reference` is not accessed at all
$result = ($a === 'not-a' && ($b || false));
|
@AndrolGenhald I just created a test-case for this, feel free to reuse them from PR #8290 |
I'll try to get this fixed soon, but I've given up on further improving support for arrays and objects with references, they're (imo) incredibly buggy and unintuitive: https://3v4l.org/3RncH |
Incredible, I was not aware of that flaw in PHP! 😮 |
Fix type reconciliation breaking Context::$references_in_scope (fixes #8289).
https://psalm.dev/r/03af5df16f
Check XHR response in browser's dev console (actually it's "just" a warning, however analyzer stops)
psalm/src/Psalm/Type/Reconciler.php
Line 128 in e268a05
The text was updated successfully, but these errors were encountered: