Skip to content

Commit

Permalink
emit more awesome error message when importing a symbol would overrid…
Browse files Browse the repository at this point in the history
…e an existing lexical

Previously that died with "Multiple declarations of lexical $symbol".
Next step: don't die when using the same module twice (don't know if that's
going to be quite as easy...)
  • Loading branch information
moritz committed Jun 23, 2010
1 parent 7b089e5 commit b043847
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Perl6/Module/Loader.pm
Expand Up @@ -125,11 +125,16 @@ method stub_lexical_imports($name, $block_ast) {
my %imports := self.get_imports($name);
unless pir::isnull__IP(%imports) {
for %imports {
$block_ast[0].push(PAST::Var.new(
:name($_.key), :scope('lexical'), :isdecl(1),
:viviself(PAST::Op.new( :pirop('null P')) )
));
$block_ast.symbol($_.key, :scope('lexical'));
if $block_ast.symbol($_.key) {
pir::die("Can't import symbol " ~ $_.key
~ " because it already exists in this lexical scope\n");
} else {
$block_ast[0].push(PAST::Var.new(
:name($_.key), :scope('lexical'), :isdecl(1),
:viviself(PAST::Op.new( :pirop('null P')) )
));
$block_ast.symbol($_.key, :scope('lexical'));
}
}
}
}
Expand Down

0 comments on commit b043847

Please sign in to comment.