Skip to content

sv: an unresolved call in a package class body binds to an importing module's function of the same name #2447

Open

Description

@tignear

A call in a package class method to a function the package does not declare is accepted, and it runs a function of the same name that the module using the class declares. Names in a package resolve in the package (IEEE 1800-2023 26.3), so the call should be an unknown-function error.

package p;
    class C #(type T = int);
        static function int run(); return helper(); endfunction
    endclass
    typedef C#(byte) Cb;
endpackage
module Top;
    function automatic int helper(); return 7; endfunction
    initial $display("%0d", p::Cb::run());   // accepted; calls Top's helper
endmodule

The package keeps the unqualified callee helper in the lowered body, and the module's subroutine of that name satisfies it. This happens on master for a specialization the package names itself, independently of the specializations that #2429 makes for importing scopes (found in its review, discussion r4399937333).

Expected

Reject an unknown function in a package body when the package is analyzed, or bind package callees by qualified name so an importing scope's routines cannot satisfy them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions