Skip to content

Language: duplicate named arguments — compile error not Zend runtime Error (Zend/zend_execute.c) #16652

Description

@PurHur

Category

Language · php-src-strict

Problem

When a call passes the same named parameter twice (f(a: 1, a: 2)), Zend raises a runtime Error that user code can catch. This compiler rejects the call at compile time (parseAndCompile failure: Named parameter $a overwrites previous argument), so catch blocks never run and exit semantics differ.

Repro Zend 8.2+ VM (2026-07-05)
try { sum(a:1,a:2,b:3); } catch (Error $e) { echo 'ok'; } ok:Named parameter $a overwrites previous argument compile failure (exit ≠ 0, body not executed)

php-src reference

PHP implementation target

  • lib/Compiler.php — defer duplicate named-parameter detection to runtime call path (or emit VM opcode that matches Zend timing); align JIT/AOT call lowering with VM
  • Reuse shared named-arg helpers; no new runtime/*.c branches

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_duplicate_named_argument.php'
# Zend baseline (prints ok:…):
php test/repro/maintainer_gap_duplicate_named_argument.php

Done when

  • test/repro/maintainer_gap_duplicate_named_argument.php prints ok: on VM and exit 0
  • Compliance .phpt guard under test/compliance/cases/language/duplicate_named_argument.phpt
  • JIT/AOT agree when call lowering is shared
  • php-src-strict; no php-compiler-strict shortcut

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITarea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions