Skip to content

&CORE::__CLASS__ returns bogus value (filename) #23737

@mauke

Description

@mauke

Description

&CORE::__CLASS__ should either fail cleanly (Undefined subroutine &CORE::__CLASS__ called or similar) or work and return a class name. Instead it returns the caller's filename.

Steps to Reproduce

use v5.36;
use experimental qw(class);

class Foo {
    method f1() { __CLASS__ }
    method f2() { &CORE::__CLASS__() }
    method f3() { \&CORE::__CLASS__ }
}

my $o = Foo->new;

say $o->f1;
say $o->f2;
say $o->f3->();

Output:

Foo
bug.pl
bug.pl

Expected behavior

Foo
Foo
Foo

... actually I'm not sure about the third one. I think that ought to be a runtime error, maybe?

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions