Skip to content

$o->m(...$args) with a string key naming no parameter binds the value to the first parameter instead of throwing "Unknown named parameter" #595

Closed

Description

@blacktrs

Summary

$o->m(...$args) with a string key naming no parameter binds the value to the first parameter instead of throwing "Unknown named parameter".

Repro

<?php
class C1 { public function __construct(public int $a = 0) {} }
function f(array $args): void { $o = new C1(); $o->__construct(...$args); echo $o->a, "\n"; }
try { f(['zz' => 1]); echo "no error\n"; } catch (\Error $e) { echo get_class($e), ': ', $e->getMessage(), "\n"; }

Expected (php)

Error: Unknown named parameter $zz

Actual (manticore c3e6998f, Darwin arm64)

1
no error

Tracking

Known-bug repro: tests/aot/repro/wrong/spread_unknown_named_param_binds_positionally.php — bash tests/aot/xfail.sh -k spread_unknown_named_param_binds_positionally reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions