Open p6rt opened 7 years ago
Code: unit module Foo; sub foo() is export {}; say Foo::EXPORT === UNIT::EXPORT # unit makes the declared package the current UNIT
Result (2016.04): True
Result (HEAD): False
Bisectable is pointing to https://github.com/rakudo/rakudo/commit/fe2be65806d907efbbaa0adc4f0175c2e23c3a40
On Wed, 28 Dec 2016 19:46:01 -0800, alex.jakimenko@gmail.com wrote:
Code: unit module Foo; sub foo() is export {}; say Foo::EXPORT === UNIT::EXPORT # unit makes the declared package the current UNIT
Result (2016.04): True
Result (HEAD): False
Bisectable is pointing to https://github.com/rakudo/rakudo/commit/fe2be65806d907efbbaa0adc4f0175c2e23c3a40
Since that commit, https://github.com/rakudo/rakudo/commit/4d85cde90883e031650600b9f55a87e86acb632c also would have regressed this behavior if it had not already been regressed, and there have been other commits since that may also.
The bug which 4d85cde9 was trying to address, #128931, pointed out that any two types with the same name had the same .WHICH.
It is proper that we should have different .WHICH's on different type objects, even if they have the same name. However, it appears that in the case of UNIT:: and perhaps some other/future PseudoStash aliases, EXPORT may be being treated as a value type and copied around... (EXPORT is immutable outside of COMPILING and metaprogramming APIs):
$ perl6 -e 'unit module Foo; use nqp; sub g is export { }; nqp::say(nqp::eqaddr(Foo::EXPORT, UNIT::EXPORT))' 0
...that will either have to be fixed, or worked around.
The RT System itself - Status changed from 'new' to 'open'
On Wed, 28 Dec 2016 19:46:01 -0800, alex.jakimenko@gmail.com wrote:
Code: unit module Foo; sub foo() is export {}; say Foo::EXPORT === UNIT::EXPORT # unit makes the declared package the current UNIT
Result (2016.04): True
Result (HEAD): False
Bisectable is pointing to https://github.com/rakudo/rakudo/commit/fe2be65806d907efbbaa0adc4f0175c2e23c3a40
OK, I looked into this some more, and I don't think it is a bug.
"unit module" is documented as such: in S02: unit # like our, but introduces a compilation-unit scoped name in S11: unit module Foo; # rest of scope is in module Foo
None of that says UNIT and unit module Foo will be the same package, just that everything in the rest of the file will be lexically inside Foo. Note that the UNIT/SETTING/CORE packages are lexical scopes and your program is the next *block* below UNIT, whereas the GLOBAL "package scope" is what is above your *package* ... so there is an apples and oranges difference between "Foo::" and "UNIT::".
The description of the EXPORT and UNIT::EXPORT classes are as such in S11:
"Every compunit has a C\
...note I think there is a typo in S11 where it says:
the lexical C\
...in that IMPORT should be EXPORT.
I don't see anything in roast that tests that the two EXPORTs are ===, so this behavior was never promised, it just "worked" by accident until other changes disrupted it.
Now the question is, what was the use case of comparing the two EXPORT stashes, and/or what behavior results from them being different which is problematic? I'd consult IRC or the mailing list to figure out a different way to do whatever this was intended to do.
Keeping this open so the spec typo may be verified by second opinion and fixed, but then we should close/reject this ticket.
Migrated from rt.perl.org#130435 (status was 'open')
Searchable as RT130435$