Skip to content

Commit

Permalink
RakuAST: support my Foo sub ... syntax for return type declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
niner committed May 1, 2024
1 parent fcbd530 commit 622f58a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Raku/Actions.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -2205,6 +2205,7 @@ class Raku::Actions is HLL::Actions does Raku::CommonActions {

method routine-def($/) {
my $routine := $*BLOCK;
my $return-type := $*OFTYPE.ast if $*OFTYPE;
if $<signature> {
$routine.replace-signature($<signature>.ast);
}
Expand Down Expand Up @@ -2908,6 +2909,11 @@ class Raku::Actions is HLL::Actions does Raku::CommonActions {
else {
$returns := Nodify('Node');
}
if $*OFTYPE {
$/.typed-sorry('X::Redeclaration', :what('return type for'))
if $returns;
$returns := $*OFTYPE.ast;
}
self.attach: $/, Nodify('Signature').new(:@parameters, :$returns);
}

Expand Down

0 comments on commit 622f58a

Please sign in to comment.