# New Ticket Created by Chris Dolan # Please include the string: [perl #60718] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=60718 >
If you accidentally try to instantiate a class that has not been defined, but the namespace for that class has been vivified, then you get an obscure error message: % perl6 -e 'class Foo::Bar::Baz { }; Foo::Bar.new;' Null PMC access in get_string() current instr.: 'parrot;Perl6Object;new' pc 277 (src/ gen_builtins.pir:190) called from Sub '_block11' pc 27 (EVAL_11:17) called from Sub 'parrot;PCT;HLLCompiler;eval' pc 898 (src/PCT/ HLLCompiler.pir:510) called from Sub 'parrot;PCT;HLLCompiler;command_line' pc 1450 (src/PCT/HLLCompiler.pir:774) called from Sub 'parrot;Perl6;Compiler;main' pc 16257 (perl6.pir: 168) With the attached patch, Rakudo instead dies with a more informative message: % perl6 -e 'class Foo::Bar::Baz { }; Foo::Bar.new;' Cannot instantiate Module. Perhaps you have not defined a class named Foo::Bar? current instr.: 'die' pc 12358 (src/gen_builtins.pir:7530) called from Sub 'parrot;Module;new' pc 8086 (src/ gen_builtins.pir:5170) called from Sub '_block11' pc 27 (EVAL_11:17) called from Sub 'parrot;PCT;HLLCompiler;eval' pc 898 (src/PCT/ HLLCompiler.pir:510) called from Sub 'parrot;PCT;HLLCompiler;command_line' pc 1450 (src/PCT/HLLCompiler.pir:774) called from Sub 'parrot;Perl6;Compiler;main' pc 16257 (perl6.pir: 168) The patch is a bit of a hack. It introduces a new() method to Module.pir which just constructs the error message and dies. Most of the added code is used to build the intended class name. Surely someone more familiar with the NameSpace pmc can improve it a bit? Module.pir | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+)
undefined_class.patch
Description: Binary data