Skip to content

Commit

Permalink
Give nqp named anon methods
Browse files Browse the repository at this point in the history
Allows for the following pattern:

```raku
nqp::getstaticcode(
    anon method introspective() {
        nqp::die('nice callstack!')
    });
```

Which would be *very* useful in Rakudo's bootstrapping, for instance.
Many of Rakudo's core methods lack names on their code objects, which
tends to be rather confusing for newcomers introspecting methods.
  • Loading branch information
Kaiepi committed May 17, 2022
1 parent f305450 commit b080820
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/NQP/Actions.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ class NQP::Actions is HLL::Actions {
# Otherwise, build method block QAST.
my $ast;
my int $onlystar;
my $package := $/.package;
my $package := $/.package;
if $<onlystar> {
$ast := only_star_block();
$onlystar := 1;
Expand Down Expand Up @@ -1062,7 +1062,7 @@ class NQP::Actions is HLL::Actions {
}
$name := "!!LATENAME!!" ~ ~$<latename>;
}
if $name ne "" {
if $name ne "" && $*SCOPE ne 'anon' {
# Set name.
$ast.name($name);

Expand Down

0 comments on commit b080820

Please sign in to comment.