Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Something is wrong with $_ topicalization in statement_mod 'for' and 'given' in Rakudo #2501

Closed
p6rt opened this issue Oct 5, 2011 · 7 comments

Comments

@p6rt
Copy link

p6rt commented Oct 5, 2011

Migrated from rt.perl.org#100746 (status was 'resolved')

Searchable as RT100746$

@p6rt
Copy link
Author

p6rt commented Oct 5, 2011

From @masak

<masak> nom​: my $t = q[%foo% %bar% %foo% %baz%]; my %b = foo => 1, bar
=> 2, baz => 3; $t.=subst("%{.key}%", .value, :g) for %b.pairs; say $t
<p6eval> nom 4f19b7​: OUTPUT«Method 'key' not found for invocant of
class 'Any' [...]
<masak> b​: my $t = q[%foo% %bar% %foo% %baz%]; my %b = foo => 1, bar
=> 2, baz => 3; $t.=subst("%{.key}%", .value, :g) for %b.pairs; say $t
<p6eval> b 1b7dd1​: OUTPUT«1 2 1 3␤»
<moritz> nom​: my %b = foo => 1, bar => 2, baz => 3; say "{.key}" for %b.pairs
<p6eval> nom 4f19b7​: OUTPUT«Method 'key' not found for invocant of
class 'Any' [...]
<moritz> b​: my %b = foo => 1, bar => 2, baz => 3; say "{.key}" for %b.pairs
<p6eval> b 1b7dd1​: OUTPUT«foo␤bar␤baz␤»
<moritz> nom​: say "{.key}" given a => 1
<p6eval> nom 4f19b7​: OUTPUT«Method 'key' not found for invocant of
class 'Any' [...]
<moritz> b​: say "{.key}" given a => 1
<p6eval> b 1b7dd1​: OUTPUT«a␤»
<moritz> nom​: $_ = a => 1; say "{.key}"
<p6eval> nom 4f19b7​: OUTPUT«a␤»
<masak> odd, no?
<moritz> yes, seems like topicalization by 'given' and 'for' does
something differently
<moritz> ... different than $_ assignment, that is
* masak submits rakudobug

@p6rt
Copy link
Author

p6rt commented Apr 5, 2013

From @coke

On Wed Oct 05 06​:05​:05 2011, masak wrote​:

<masak> nom​: my $t = q[%foo% %bar% %foo% %baz%]; my %b = foo => 1, bar
=> 2, baz => 3; $t.=subst("%{.key}%", .value, :g) for %b.pairs; say $t
<p6eval> nom 4f19b7​: OUTPUT«Method 'key' not found for invocant of
class 'Any' [...]
<masak> b​: my $t = q[%foo% %bar% %foo% %baz%]; my %b = foo => 1, bar
=> 2, baz => 3; $t.=subst("%{.key}%", .value, :g) for %b.pairs; say $t
<p6eval> b 1b7dd1​: OUTPUT«1 2 1 3␤»
<moritz> nom​: my %b = foo => 1, bar => 2, baz => 3; say "{.key}" for
%b.pairs
<p6eval> nom 4f19b7​: OUTPUT«Method 'key' not found for invocant of
class 'Any' [...]
<moritz> b​: my %b = foo => 1, bar => 2, baz => 3; say "{.key}" for
%b.pairs
<p6eval> b 1b7dd1​: OUTPUT«foo␤bar␤baz␤»
<moritz> nom​: say "{.key}" given a => 1
<p6eval> nom 4f19b7​: OUTPUT«Method 'key' not found for invocant of
class 'Any' [...]
<moritz> b​: say "{.key}" given a => 1
<p6eval> b 1b7dd1​: OUTPUT«a␤»
<moritz> nom​: $_ = a => 1; say "{.key}"
<p6eval> nom 4f19b7​: OUTPUT«a␤»
<masak> odd, no?
<moritz> yes, seems like topicalization by 'given' and 'for' does
something differently
<moritz> ... different than $_ assignment, that is
* masak submits rakudobug

These all now work like b did. Closable with tests.

./perl6

my $t = q[%foo% %bar% %foo% %baz%]; my %b = foo => 1, bar => 2, baz => 3; $t.=subst("%
{.key}%", .value, :g) for %b.pairs; say $t
1 2 1 3
my %b = foo => 1, bar => 2, baz => 3; say "{.key}" for %b.pairs
foo
bar
baz
say "{.key}" given a => 1
a
$_ = a => 1; say "{.key}"
a

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Apr 5, 2013

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Apr 19, 2015

From @usev6

As a status update​: we're back at the original failures​:

$ perl6 -e 'my $t = q[%foo% %bar% %foo% %baz%]; my %b = foo => 1, bar => 2, baz => 3; $t.=subst("%{.key}%", .value, :g) for %b.pairs; say $t'
Method 'key' not found for invocant of class 'Any'
  in block <unit> at -e​:1

$ perl6-m -e 'my %b = foo => 1, bar => 2, baz => 3; say "{.key}" for %b.pairs'
Method 'key' not found for invocant of class 'Any'
  in block <unit> at -e​:1

$ perl6 -e 'say "{.key}" given a => 1'
Method 'key' not found for invocant of class 'Any'
  in block <unit> at -e​:1

It works when for is followed by a block (instead of the statement_mod form)

$ perl6 -e 'my %b = foo => 1, bar => 2, baz => 3; for %b.pairs { say "{.key}" }'
foo
bar
baz

1 similar comment
@p6rt
Copy link
Author

p6rt commented Apr 19, 2015

From @usev6

As a status update​: we're back at the original failures​:

$ perl6 -e 'my $t = q[%foo% %bar% %foo% %baz%]; my %b = foo => 1, bar => 2, baz => 3; $t.=subst("%{.key}%", .value, :g) for %b.pairs; say $t'
Method 'key' not found for invocant of class 'Any'
  in block <unit> at -e​:1

$ perl6-m -e 'my %b = foo => 1, bar => 2, baz => 3; say "{.key}" for %b.pairs'
Method 'key' not found for invocant of class 'Any'
  in block <unit> at -e​:1

$ perl6 -e 'say "{.key}" given a => 1'
Method 'key' not found for invocant of class 'Any'
  in block <unit> at -e​:1

It works when for is followed by a block (instead of the statement_mod form)

$ perl6 -e 'my %b = foo => 1, bar => 2, baz => 3; for %b.pairs { say "{.key}" }'
foo
bar
baz

@p6rt
Copy link
Author

p6rt commented Apr 28, 2015

From @jnthn

On Sun Apr 19 02​:54​:22 2015, bartolin@​gmx.de wrote​:

As a status update​: we're back at the original failures​:

$ perl6 -e 'my $t = q[%foo% %bar% %foo% %baz%]; my %b = foo => 1, bar
=> 2, baz => 3; $t.=subst("%{.key}%", .value, :g) for %b.pairs; say
$t'
Method 'key' not found for invocant of class 'Any'
in block <unit> at -e​:1

$ perl6-m -e 'my %b = foo => 1, bar => 2, baz => 3; say "{.key}" for
%b.pairs'
Method 'key' not found for invocant of class 'Any'
in block <unit> at -e​:1

$ perl6 -e 'say "{.key}" given a => 1'
Method 'key' not found for invocant of class 'Any'
in block <unit> at -e​:1

It works when for is followed by a block (instead of the statement_mod
form)

$ perl6 -e 'my %b = foo => 1, bar => 2, baz => 3; for %b.pairs { say
"{.key}" }'
foo
bar
baz

Fixed and unfudged tests in S04-statement-modifier/for.t and S04-statement-modifier/given.t.

@p6rt p6rt closed this as completed Apr 28, 2015
@p6rt
Copy link
Author

p6rt commented Apr 28, 2015

@jnthn - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant