Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/perl5Public

mark CORE::__CLASS__ as non-ampable#23740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mauke merged 4 commits intoPerl:bleadfrommauke:fix-23737-amp-core-class
Sep 22, 2025

Conversation

@mauke
Copy link
Contributor

Previously:CORE::__CLASS__ and compile-time aliasing (as inBEGIN { *cls = \&CORE::__CLASS__; } ... cls) worked as expected, but runtime calls like&CORE::__CLASS__() andmy $ref = \&CORE::__CLASS__; ... $ref->() would produce bizarre results, behaving likeCORE::__FILE__ instead.

Now the latter throw a&CORE::__CLASS__ cannot be called directly error. This is perhaps not entirely satisfactory, but__CLASS__ is a bit special (it is not a true constant and only usable in methods) and erroring cleanly is better than silently returning wrong results.

Fixes#23737.

Partially subsumes#23343.


  • This set of changes requires a perldelta entry, and it is included.

Previously: CORE::__CLASS__ and compile-time aliasing (as in `BEGIN {*cls = \&CORE::__CLASS__; } ... cls`) worked as expected, but runtimecalls like `&CORE::__CLASS__()` and `my $ref = \&CORE::__CLASS__; ...$ref->()` would produce bizarre results, behaving like CORE::__FILE__instead.Now the latter throw a "&CORE::__CLASS__ cannot be called directly"error. This is perhaps not entirely satisfactory, but __CLASS__ is a bitspecial (it is not a true constant and only usable in methods) anderroring cleanly is better than silently returning wrong results.FixesPerl#23737.Assorted changes:- Document core_prototype()'s `opnum` parameter.- Add comment explaining what `*opnum = 0` means (and why it makes no  sense for KEY___CLASS__).- Don't hardcode assumptions about keyword codes in coresub_op(). Handle  __PACKAGE__/__FILE__/__LINE__ explicitly and assert() nothing else is  passed in. This effectively reverts commitc2f605d.- Remove CORE::__CLASS__ from op/coreamp.t as it is no longer "ampable".- Extend op/coresubs.t to handle more of the idiosyncrasies of  CORE::__CLASS__.
Rearrange documentation slightly to make it clearer what you can(not) dowith CORE::chomp, CORE::chop, etc. and add CORE::__CLASS__ to the list.
coresub_op() no longer hardcodes assumptions about the numeric values of__FILE__, __LINE__, __PACKAGE__ keyword symbols.
Copy link
Contributor

@leonerdleonerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Overall LGTM, but I'd suggest some adjustment to the perldelta.

@maukemaukeforce-pushed thefix-23737-amp-core-class branch fromc7d59f7 to053aa58CompareSeptember 20, 2025 14:41
@maukemauke merged commitd143571 intoPerl:bleadSep 22, 2025
33 checks passed
@maukemauke deleted the fix-23737-amp-core-class branchSeptember 22, 2025 02:06
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@leonerdleonerdleonerd left review comments

+1 more reviewer

@happy-barneyhappy-barneyhappy-barney left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

&CORE::__CLASS__ returns bogus value (filename)

3 participants

@mauke@leonerd@happy-barney

[8]ページ先頭

©2009-2025 Movatter.jp