From d06b7515cc38e9af56736eaaf82116873e2ac5b2 Mon Sep 17 00:00:00 2001 From: Ben Davies Date: Tue, 17 May 2022 02:41:25 -0300 Subject: [PATCH] Give nqp named anon methods 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. --- src/NQP/Actions.nqp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NQP/Actions.nqp b/src/NQP/Actions.nqp index ab14ec670..799d8f1d0 100644 --- a/src/NQP/Actions.nqp +++ b/src/NQP/Actions.nqp @@ -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 $ { $ast := only_star_block(); $onlystar := 1; @@ -1062,7 +1062,7 @@ class NQP::Actions is HLL::Actions { } $name := "!!LATENAME!!" ~ ~$; } - if $name ne "" { + if $name && $*SCOPE ne 'anon' { # Set name. $ast.name($name);