Skip to content

Function JIT emits "could not convert to int" warning at the same time as invalid offset Error #12748

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 = "string";
// 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():
bool(false)
empty():
bool(true)
Coalesce():

Warning: Object of class stdClass could not be converted to int in %s on line %d
Cannot access offset of type stdClass on string

But I expected this output instead:

isset():
bool(false)
empty():
bool(true)
Coalesce():
Cannot access offset of type stdClass on string

Related to #12723

PHP Version

PHP 8.2-dev

Operating System

No response

dstogov added a commit that referenced this issue Nov 22, 2023
* PHP-8.2:
  Fixed GH-12748: Function JIT emits "could not convert to int" warning at the same time as invalid offset Error
dstogov added a commit that referenced this issue Nov 22, 2023
* PHP-8.3:
  Fixed GH-12748: Function JIT emits "could not convert to int" warning at the same time as invalid offset Error
ramsey pushed a commit that referenced this issue Nov 23, 2023
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