Stop constant inlining from countermanding ‘use subs’
Ever since
commit
f7461760003db2ce68155c97ea6c1658e96fcd27
Author: Zefram <zefram@fysh.org>
Date: Sun Nov 8 15:03:45 2009 +0100
Bareword sub lookups
...
this has failed:
$ perl5.10 -le 'use subs "abs"; sub abs() {44}; print abs + abs'
88
$ perl5.12 -le 'use subs "abs"; sub abs() {44}; print abs + abs'
44
A GV holding a single constant is a candidate for downgrading after
it uhas been used. The GV gets downgraded after the first ‘abs’ is
inlined. In the process, the CV-imported flag, which is stored in the
GV, not the CV, is lost, preventing &abs from overriding the built-in
function on the second mention.
There is a special flag for RVs, namely SVprv_PCS_IMPORTED,
which indicates that, when expanded to GVs, they should have the
GVf_IMPORTED_CV flag set. But gv_try_downgrade wasn‘t setting
that flag.