summaryrefslogtreecommitdiff
path: root/embed.fnc
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-01-23 21:45:21 -0800
committerFather Chrysostomos <sprout@cpan.org>2012-01-23 22:11:19 -0800
commit7e68c38b607a044ee5879e316bb8a7347284ec8e (patch)
treef2ec4605547641308b3701628ffc37e9a90d7465 /embed.fnc
parent6fa2c250307a2b1de4850e25cb3eb81bc16c7244 (diff)
downloadperl-7e68c38b607a044ee5879e316bb8a7347284ec8e.tar.gz
[rt.cpan.org #74289] Don’t make *CORE::foo read-only
newATTRSUB requires the sub name to be passed to it wrapped up in a const op. Commit 8756617677dbd allowed it to accept a GV that way, since S_maybe_add_coresub (in gv.c) needed to pass it an existing GV not in the symbol table yet (to simplify code elsewhere). This had the inadvertent side-effect of making the GV read-only, since that’s what the check function for const ops does. Even if we were to call this a feature, it wouldn’t make sense as implemented, as GVs for non-ampable (&-able) subs like *CORE::chdir were not being made read-only. This commit adds a new flag to newATTRSUB, to allow a GV to be passed as the o parameter, instead of an op. While this may look as though it’s undoing the simplification in commit 8756617677dbd by adding more code, the new code is still conceptually simpler and more straightforward. Since newATTRSUB is in the API, I had to add a new _flags variant. (How did newATTRSUB get into the API to begin with?) In adding a test, I also discovered that ‘used once’ warnings were applying to these subs, which is obviously wrong. Commit 8756617677dbd caused that, too, as it was relying on the side-effect of newATTRSUB doing a GV lookup. This fixes that, too, by turning on the multi flag in S_maybe_add_coresub.
Diffstat (limited to 'embed.fnc')
-rw-r--r--embed.fnc3
1 files changed, 3 insertions, 0 deletions
diff --git a/embed.fnc b/embed.fnc
index d6980d609c..3d79971a2a 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -1590,6 +1590,9 @@ Apd |SV* |sv_rvweaken |NN SV *const sv
p |int |magic_killbackrefs|NN SV *sv|NN MAGIC *mg
Ap |OP* |newANONATTRSUB |I32 floor|NULLOK OP *proto|NULLOK OP *attrs|NULLOK OP *block
Ap |CV* |newATTRSUB |I32 floor|NULLOK OP *o|NULLOK OP *proto|NULLOK OP *attrs|NULLOK OP *block
+p |CV* |newATTRSUB_flags|I32 floor|NULLOK OP *o|NULLOK OP *proto \
+ |NULLOK OP *attrs|NULLOK OP *block \
+ |U32 flags
#ifdef PERL_MAD
Apr |OP * |newMYSUB |I32 floor|NULLOK OP *o|NULLOK OP *proto \
|NULLOK OP *attrs|NULLOK OP *block