If given a namespace key with a single component, and a name that is not found, e.g.
$P2 = find_global ["Foo"], "bazz" Parrot says "Global 'bazz' not found", obeying PARROT_ERRORS_GLOBALS_FLAG (presumably). On the other hand, if the namespace name is compound: $P2 = find_global ["Foo";"Bar"], "bazz" find_global just returns the null PMC, ignoring PARROT_ERRORS_GLOBALS_FLAG. I'm not exactly sure why -- compile-time constant folding of the key? -- but the attached patch makes the latter code also throw an error. If nobody objects in the next day, I will commit it. -- Bob Rogers http://rgrjr.dyndns.org/
Index: src/ops/experimental.ops =================================================================== --- src/ops/experimental.ops (revision 12894) +++ src/ops/experimental.ops (working copy) @@ -276,7 +276,7 @@ } op find_global(out PMC, in KEY, in STR) { - $1 = Parrot_find_global_p(interpreter, $2, $3); + $1 = Parrot_get_global_p(interpreter, $2, $3); goto NEXT(); } Index: t/pmc/namespace.t =================================================================== --- t/pmc/namespace.t (revision 12894) +++ t/pmc/namespace.t (working copy) @@ -6,7 +6,7 @@ use warnings; use lib qw( . lib ../lib ../../lib ); use Test::More; -use Parrot::Test tests => 29; +use Parrot::Test tests => 31; use Parrot::Config; =head1 NAME @@ -155,6 +155,27 @@ baz OUTPUT +pir_output_like(<<'CODE', <<'OUTPUT', "find_global Foo::bazz not found"); +.sub 'main' :main + $P2 = find_global ["Foo"], "bazz" + $P2() + print "ok\n" +.end +CODE +/Global 'bazz' not found/ +OUTPUT + +# [this used to behave differently from the previous case.] +pir_output_like(<<'CODE', <<'OUTPUT', "find_global Foo::Bar::bazz not found"); +.sub 'main' :main + $P2 = find_global ["Foo";"Bar"], "bazz" + $P2() + print "ok\n" +.end +CODE +/Global 'bazz' not found/ +OUTPUT + pir_output_is(<<'CODE', <<'OUTPUT', "find_global Foo::Bar::baz hash"); .sub 'main' :main $P0 = find_global "Foo"