perl5 icon indicating copy to clipboard operation
perl5 copied to clipboard

no bareword_filehandes: don't look up class barewords as handles

Open tonycoz opened this issue 2 years ago • 4 comments

This prevents SomeBareword from being looked up as a filehandle:

no feature "bareword_filehandles"; SomeBareword->method();

Since "bareword_filehandles" is explicitly about bareword handles, it does not prevent other string to object/class look ups from resolving the class as a filehandle, eg for the following:

"SomeLiteral"->method(); my $x = "SomeVariable"; $x->method();

both are looked up as file handles per normal.

Note that in any of these cases, with or without the bareword_filehandles feature, if the name is a bareword that has been resolved as a class name since the last time the stash cache was cleared, it will be resolved as a class name, not a filehandle.

Fixes #19426

tonycoz avatar Jun 20 '23 23:06 tonycoz

I don't believe this belongs in 5.38 at this stage, it may change the behaviour of working code.

tonycoz avatar Jun 20 '23 23:06 tonycoz

I don't believe this belongs in 5.38 at this stage, it may change the behaviour of working code.

@tonycoz, do you still want to pursue this p.r. (now that we're past 5.38.0)? If so, you will need to resolve some conflicts. Thanks.

jkeenan avatar Nov 22 '23 22:11 jkeenan

Rebased, waiting for review, preferably on both the behaviour and the implementation.

tonycoz avatar Nov 22 '23 23:11 tonycoz

Added one comment about the implementation, but I think overall the intent of the behaviour is good. It means that with that feature enabled, the behaviour of "Name->foo" is simpler to explain and reason about, because it doesn't depend on (dynamic) filehandle setup any more.

leonerd avatar Feb 18 '24 21:02 leonerd