Skip to content
Permalink
Browse files

Implement more fine-grained deconting of exported symbols

The problem with containerized exports has been narrowed down to EXPORT
sub using hash for declaring exports where all values are getting
wrapped into Scalars. To fix that method import on World got a named
parameter :need-decont which signals that imported symbols need to be
checked for their sigils. Unless a sigil is $ or & the symbol value is
nqp::decont'ed.

This commit works for both #2979 and #3012.
  • Loading branch information...
vrurg committed Jun 22, 2019
1 parent 3979acc commit 93f20871e0a3d032121cfc460932500279e79ba3
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/Perl6/World.nqp
@@ -1068,7 +1068,7 @@ class Perl6::World is HLL::World {
my $Map := self.find_symbol(['Map'], :setting-only);
if nqp::istype($result, $Map) {
my $storage := $result.hash.FLATTENABLE_HASH();
self.import($/, $storage, $package_source_name);
self.import($/, $storage, $package_source_name, :need-decont);
# $/.check_LANG_oopsies("do_import");
}
else {
@@ -1478,7 +1478,7 @@ class Perl6::World is HLL::World {
}

# Imports symbols from the specified stash into the current lexical scope.
method import($/, %stash, $source_package_name) {
method import($/, %stash, $source_package_name, :$need-decont = 0) {
# What follows is a two-pass thing for historical reasons.
my $target := self.cur_lexpad();

@@ -1489,6 +1489,9 @@ class Perl6::World is HLL::World {
my @clash_onlystar;
for sorted_keys(%stash) -> $key {
my $value := %stash{$key};
if $need-decont && nqp::islt_i(nqp::index('$&', nqp::substr($key,0,1)),0) {
$value := nqp::decont($value);
}
if $target.symbol($key) -> %sym {
# There's already a symbol. However, we may be able to merge
# if both are multis and have onlystar dispatchers.

0 comments on commit 93f2087

Please sign in to comment.
You can’t perform that action at this time.