Skip to content

Commit

Permalink
Fix our scoped nested package swallowed by lexically scoped parent
Browse files Browse the repository at this point in the history
In "use Foo; class Foo::Bar { }" Foo::Bar would be created as child of
the lexically imported Foo class and was thus missing from the globals.
Previous fixes only handled the case when Foo was a stub package, not
when it was a full class.
Remove the special case and fix the follow up bug that we now got a
duplicate symbol when trying to lexically override classes in the
RESTRICTED setting. There's no need to upgrade the main package to a
global if we only want to create a lexically scoped child anyway.
  • Loading branch information
niner committed Oct 31, 2016
1 parent 45d12e0 commit 6e5d96a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Perl6/World.nqp
Expand Up @@ -1346,7 +1346,7 @@ class Perl6::World is HLL::World {
my $longname := '';
if +@parts {
try {
$cur_pkg := self.find_symbol([@parts[0]], :upgrade_to_global);
$cur_pkg := self.find_symbol([@parts[0]], :upgrade_to_global($create_scope ne 'my'));
$cur_lex := 0;
$create_scope := 'our';
$longname := @parts.shift();
Expand Down Expand Up @@ -3787,7 +3787,7 @@ class Perl6::World is HLL::World {
my %sym := @BLOCKS[$i].symbol($final_name);
if +%sym {
my $value := self.force_value(%sym, $final_name, 1);
if $upgrade_to_global && $value.HOW.HOW.name($value.HOW) eq 'Perl6::Metamodel::PackageHOW' {
if $upgrade_to_global {
($*GLOBALish.WHO){$final_name} := $value;
}
return $value;
Expand Down

0 comments on commit 6e5d96a

Please sign in to comment.