Skip to content

Commit

Permalink
Fix name conflicts of auto-generated proto declarations
Browse files Browse the repository at this point in the history
These "declarations" don't need a name. They are only there so the
auto-generated proto gets added to the QAST somewhere.
  • Loading branch information
niner committed Oct 23, 2022
1 parent 874becf commit 522f1b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Raku/ast/code.rakumod
Expand Up @@ -943,7 +943,7 @@ class RakuAST::Routine is RakuAST::LexicalScope is RakuAST::Term is RakuAST::Cod
$proto := $proto-ast.meta-object;

$scope.add-generated-lexical-declaration(
RakuAST::VarDeclaration::Implicit::Block.new(:$name, :block($proto-ast))
RakuAST::VarDeclaration::Implicit::Block.new(:block($proto-ast))
);
}
$scope.add-generated-lexical-declaration(
Expand Down
7 changes: 4 additions & 3 deletions src/Raku/ast/variable-declaration.rakumod
Expand Up @@ -955,12 +955,11 @@ class RakuAST::VarDeclaration::Implicit::Constant is RakuAST::VarDeclaration::Im
}

# An implicitly declared block (like an auto-generated proto)
class RakuAST::VarDeclaration::Implicit::Block is RakuAST::VarDeclaration::Implicit {
class RakuAST::VarDeclaration::Implicit::Block is RakuAST::Declaration {
has Mu $.block;

method new(str :$name!, Mu :$block!, str :$scope) {
method new(Mu :$block!, str :$scope) {
my $obj := nqp::create(self);
nqp::bindattr_s($obj, RakuAST::VarDeclaration::Implicit, '$!name', $name);
nqp::bindattr($obj, RakuAST::VarDeclaration::Implicit::Block, '$!block', $block);
nqp::bindattr_s($obj, RakuAST::Declaration, '$!scope', $scope);
$obj
Expand All @@ -969,6 +968,8 @@ class RakuAST::VarDeclaration::Implicit::Block is RakuAST::VarDeclaration::Impli
method IMPL-QAST-DECL(RakuAST::IMPL::QASTContext $context) {
$!block.IMPL-QAST-DECL-CODE($context);
}

method lexical-name() { '' }
}

# The implicit `self` term declaration for the invocant.
Expand Down

0 comments on commit 522f1b0

Please sign in to comment.