perl5 icon indicating copy to clipboard operation
perl5 copied to clipboard

`__CLASS__` doesn't issue an experimental warning

Open ikegami opened this issue 1 year ago • 2 comments

tags: 5.40.0 core class experimental warnings

__CLASS__ doesn't issue an warning identifying it as experimental like class, field, ADJUST, etc do.

$ perl -v | grep 'This is'
This is perl 5, version 40, subversion 0 (v5.40.0) built for x86_64-linux-thread-multi

$ perl -e'use feature qw( class ); class Foo { }'
class is experimental at -e line 1.

$ perl -e'use feature qw( class ); field'
field is experimental at -e line 1.
Cannot 'field' outside of a 'class' at -e line 1.

$ perl -e'use feature qw( class ); ADJUST { }'
ADJUST is experimental at -e line 1.
Cannot 'ADJUST' outside of a 'class' at -e line 1.

$ perl -e'use feature qw( class ); __CLASS__'
Cannot use __CLASS__ outside of a method or field initializer expression at -e line 1.

It's moot since it can't be used outside of class and using class does warn, but it's inconsistent with other such keywords, and it could become important if class stops being experimental before __CLASS__.

ikegami avatar Jun 16 '24 14:06 ikegami

I believe that's reasonable since method (and all other) keyword(s) also warns:

> perl -Mfeature=class -E "method {}"

method is experimental at -e line 1.

Cannot 'method' outside of a 'class' at -e line 1.

Searching I couldn't locate where to mark that as experimental, and that's not documented in:

https://github.com/Perl/perl5/blob/blead/pod/perldiag.pod

rwp0 avatar Jun 16 '24 16:06 rwp0

@leonerd, can you take a look at this ticket? Thanks.

jkeenan avatar Jun 18 '24 17:06 jkeenan

I'm trying to address this very issue in https://github.com/Perl/perl5/pull/22387 as linked above.

It seems the place to look at was within the toke.c file where the other class-keywords are set to warn such as ADJUST.

rwp0 avatar Jul 09 '24 22:07 rwp0