Skip to content

Commit

Permalink
Make World's is_type method more reliable
Browse files Browse the repository at this point in the history
Sometimes it was treating a lexical sigilless as a type causing obscure
compiler errors.

Fixes #5027
  • Loading branch information
vrurg committed Aug 15, 2022
1 parent 10feda1 commit 13f7416
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Perl6/World.nqp
Expand Up @@ -367,6 +367,16 @@ class Perl6::World is HLL::World {
0;
}

method find_lexical(str $name) {
my int $i := +@!PADS;
while $i > 0 {
$i := $i - 1;
my %sym := @!PADS[$i].symbol($name);
return %sym if +%sym;
}
nqp::null()
}

# Checks if the symbol is really an alias to an attribute.
method is_attr_alias(str $name) {
my int $i := +@!PADS;
Expand Down Expand Up @@ -4906,7 +4916,10 @@ class Perl6::World is HLL::World {
method is_type(@name) {
my $is_name := 0;
try {
# This throws if it's not a known name.
# This throws if it's not a known name. This also includes cases where @name[0] happens not to be a str.
if +@name == 1 && +(my %sym := self.context().find_lexical(~@name[0])) {
return 0 if nqp::existskey(%sym, 'descriptor');
}
$is_name := !nqp::isconcrete(self.find_symbol(@name))
}
$is_name
Expand Down

0 comments on commit 13f7416

Please sign in to comment.