Skip to content

A qualified call to an undefined function (foo\f() in namespace A) falls back to A\f / the global function instead of throwing. #377

Closed

Description

@blacktrs

Summary

A qualified call to an undefined function (foo\f() in namespace A) falls back to A\f / the global function instead of throwing.

Repro

<?php
namespace A;

function f(): string { return "A\\f called"; }

foreach (['foo\f', '\B\strlen'] as $which) {
    try {
        if ($which === 'foo\f') {
            echo foo\f(), "\n";
        } else {
            echo \B\strlen('abc'), "\n";
        }
    } catch (\Error $e) {
        echo get_class($e), ": ", $e->getMessage(), "\n";
    }
}
echo f(), ' ', \strlen('abcd'), ' ', strlen('ab'), "\n";

Expected (php)

Error: Call to undefined function A\foo\f()
Error: Call to undefined function B\strlen()
A\f called 4 2

Actual (manticore 5bb7764c, Darwin arm64)

A\f called
3
A\f called 4 2

Tracking

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

Activity

  1. added
    bug
    wrong-answer
    on Oct 20, 2026
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