Skip to content

RW operation on readonly property doesn't throw with JIT #8863

Closed
@iluuu1994

Description

@iluuu1994

Description

The following code:

--TEST--
Readonly RW doesn't throw with JIT
--FILE--
<?php

class Test {
    public readonly int $prop;

    public function __construct() {
        $this->prop = 1;
    }

    public function rw() {
        $this->prop += 1;
        echo "Done\n";
    }
}

$test = new Test();
try {
    $test->rw();
} catch (Error $e) {
    echo $e->getMessage(), "\n";
}

?>
--EXPECT--
Cannot modify readonly property Test::$prop

Resulted in this output:

Done

But I expected this output instead:

Cannot modify readonly property Test::$prop

Discovered in #8188.

PHP Version

PHP 8.1.7

Operating System

Fedora 36

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions