Skip to content
Permalink
Browse files

[6.d] 🧙‍♂️ Cast a spell of silence on $()/@()/%()

Per 6.d-prep[^1], remove all magick from $()/@()/%() and make them
mean the same thing as $( )/@( )/%( ) (that is, contextualizers that
call .item/.list/.hash respectively on an empty list).

Closes RT#131392 and R#1946

[1] https://github.com/perl6/6.d-prep/blob/dffa2642419a0f481591b9b64b602bfc4c4eb66b/TODO/FEATURES.md#remove--magicalness-from--and-
[2] https://rt.perl.org/Public/Bug/Display.html?id=131392
[3] #1946
  • Loading branch information...
zoffixznet committed Sep 20, 2018
1 parent abbbd2a commit bb88a0324ee8fd73c2f566811fa08d237c831487
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/Perl6/Actions.nqp
@@ -3091,7 +3091,9 @@ class Perl6::Actions is HLL::Actions does STDActions {

method contextualizer($/) {
my $past := $<coercee>.ast;
if $<sigil> eq '$' && ~$<coercee> eq '' { # for '$()'
my $has_magic := $*W.lang-ver-before('d') && $<coercee> eq '';

if $has_magic && $<sigil> eq '$' { # for '$()'
my $result_var := $past.unique('sm_result');
$past := QAST::Stmt.new(
# Evaluate RHS and call ACCEPTS on it, passing in $_. Bind the
@@ -3127,7 +3129,7 @@ class Perl6::Actions is HLL::Actions does STDActions {
~$<sigil> eq '%' ?? 'hash' !!
'item';
# @() and %()
$past := QAST::Var.new( :name('$/'), :scope('lexical') ) if ~$<coercee> eq '';
$past := QAST::Var.new( :name('$/'), :scope('lexical') ) if $has_magic;

$past := QAST::Op.new( :op('callmethod'), :name($name), $past );
}

0 comments on commit bb88a03

Please sign in to comment.
You can’t perform that action at this time.