Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix resolve_reposession_conflicts not resolving anything
The code still iterated over $orig.FLATTENABLE_HASH as needed in NQP but which
doesn't actually work in Perl 6. It also lacked recursive merging of stashes,
i.e. with Foo::Bar::Baz and Foo::Bar::Qux we would lose the first one as we
found a "Bar" in $current and assumed it was the same.

Both issues can be fixed by using merge-symbols which gives us the same
semantics as during compilation, with the exception of our scoped functions.
No idea how they could even conflict when they are in different packages like
NativeCall's &mangle_cpp_symbol. But as it seems to work and unification of
compilation and module loading semantics can only be a good thing, we adopt the
"latest wins" semantics of resolve_reposession_conflicts in merge_globals for
now.
  • Loading branch information
niner committed Dec 14, 2015
1 parent 7c4b456 commit b384d8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/Perl6/ModuleLoader.nqp
Expand Up @@ -161,6 +161,10 @@ class Perl6::ModuleLoader does Perl6::ModuleLoaderVMConfig {
self.merge_globals($_.value.WHO, ($target){$sym}.WHO);
($target){$sym} := $_.value;
}
elsif nqp::eqat($_.key, '&', 0) {
# "Latest wins" semantics for functions
($target){$sym} := $_.value;
}
else {
nqp::die("P6M Merging GLOBAL symbols failed: duplicate definition of symbol $sym");
}
Expand Down
6 changes: 1 addition & 5 deletions src/core/CompUnit/RepositoryRegistry.pm
Expand Up @@ -199,11 +199,7 @@ RAKUDO_MODULE_DEBUG("Looking in $spec for $name")
# If it's a Stash in conflict, we make sure any original entries get
# appropriately copied.
if $orig.HOW.name($orig) eq 'Stash' {
for $orig.FLATTENABLE_HASH() {
if !nqp::existskey($current, $_.key) || nqp::eqat($_.key, '&', 0) {
$current{$_.key} := $_.value;
}
}
$current.merge-symbols($orig);
}
# We could complain about anything else, and may in the future; for
# now, we let it pass by with "latest wins" semantics.
Expand Down

0 comments on commit b384d8f

Please sign in to comment.