Skip to content

Function JIT returns invalid error message for coalesce operator on invalid offset #12747

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

Closed
Girgias opened this issue Nov 22, 2023 · 0 comments

Comments

@Girgias
Copy link
Member

Girgias commented Nov 22, 2023

Description

The following code:

<?php

$container = [];

// Is
try {
    echo "isset():\n";
    var_dump(isset($container[new stdClass()]));
} catch (\Throwable $e) {
    echo $e->getMessage(), "\n";
}
try {
    echo "empty():\n";
    var_dump(empty($container[new stdClass()]));
} catch (\Throwable $e) {
    echo $e->getMessage(), "\n";
}
try {
    echo "Coalesce():\n";
    var_dump($container[new stdClass()] ?? 'default');
} catch (\Throwable $e) {
    echo $e->getMessage(), "\n";
}

?>

Resulted in this output:

isset():
Cannot access offset of type stdClass in isset or empty
empty():
Cannot access offset of type stdClass in isset or empty
Coalesce():
Cannot access offset of type stdClass in isset or empty

But I expected this output instead:

isset():
Cannot access offset of type stdClass in isset or empty
empty():
Cannot access offset of type stdClass in isset or empty
Coalesce():
Cannot access offset of type stdClass on array

Related to #12723

PHP Version

PHP 8.3-dev

Operating System

No response

dstogov added a commit that referenced this issue Nov 22, 2023
* PHP-8.3:
  Fixed GH-12747: Function JIT returns invalid error message for coalesce operator on invalid offset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants