Skip to content

Commit

Permalink
Make compiler look for exceptions in setting only.
Browse files Browse the repository at this point in the history
If people declared a package X, it could hide the X namespace for
exceptions, so the compiler could not find its exception types to
throw for things like syntax errors. This has led to all manner of
confusion. So, now we only look for those in the current setting.
  • Loading branch information
jnthn committed Jun 29, 2015
1 parent 60c273d commit 150df80
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Perl6/World.nqp
Expand Up @@ -3076,7 +3076,7 @@ class Perl6::World is HLL::World {
# Finds a symbol that has a known value at compile time from the
# perspective of the current scope. Checks for lexicals, then if
# that fails tries package lookup.
method find_symbol(@name) {
method find_symbol(@name, :$setting-only) {
# Make sure it's not an empty name.
unless +@name { nqp::die("Cannot look up empty name"); }

Expand All @@ -3089,7 +3089,7 @@ class Perl6::World is HLL::World {
# scopes.
if +@name == 1 {
my $final_name := @name[0];
my int $i := +@!BLOCKS;
my int $i := $setting-only ?? 1 !! +@!BLOCKS;
while $i > 0 {
$i := $i - 1;
my %sym := @!BLOCKS[$i].symbol($final_name);
Expand All @@ -3105,7 +3105,7 @@ class Perl6::World is HLL::World {
my $result := $*GLOBALish;
if +@name >= 2 {
my $first := @name[0];
my int $i := +@!BLOCKS;
my int $i := $setting-only ?? 1 !! +@!BLOCKS;
while $i > 0 {
$i := $i - 1;
my %sym := @!BLOCKS[$i].symbol($first);
Expand Down Expand Up @@ -3385,8 +3385,10 @@ class Perl6::World is HLL::World {
nqp::print("Error while constructing error object:");
nqp::say($_);
};
$ex := self.find_symbol(nqp::islist($ex_type) ?? $ex_type !! nqp::split('::', $ex_type));
my $x_comp := self.find_symbol(['X', 'Comp']);
$ex := self.find_symbol(
nqp::islist($ex_type) ?? $ex_type !! nqp::split('::', $ex_type),
:setting-only);
my $x_comp := self.find_symbol(['X', 'Comp'], :setting-only);
unless nqp::istype($ex, $x_comp) {
$ex := $ex.HOW.mixin($ex, $x_comp);
}
Expand Down

0 comments on commit 150df80

Please sign in to comment.