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

Parrot string indexing semantics leaks through when accessing $1 et al. when $/ contains a Str in Rakudo #1441

Closed
p6rt opened this issue Dec 16, 2009 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Dec 16, 2009

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

Searchable as RT71362$

@p6rt
Copy link
Author

p6rt commented Dec 16, 2009

From @masak

<masak> rakudo​: $/ = "abc"; say $1
<p6eval> rakudo 55f51d​: b␤
<masak> hihi.
* masak submits rakudobug
<pmichaud> rakudo​: my $a = 'abc'; say $a[1];
<p6eval> rakudo 55f51d​: Method 'postcircumfix​:[ ]' not found for
invocant of class 'Str' [...]
<pmichaud> heh
<pmichaud> interesting
<pmichaud> rakudo​: $/ = "abc"; say $/[1]
<p6eval> rakudo 55f51d​: Method 'postcircumfix​:[ ]' not found for
invocant of class 'Str' [...]
<pmichaud> oh, I get it.
<masak> pmichaud​: it's PIR semantics leaking through in exactly that case.
<pmichaud> masak++
<pmichaud> masak​: right.

@p6rt
Copy link
Author

p6rt commented Jul 28, 2010

From @coke

On Wed Dec 16 07​:03​:22 2009, masak wrote​:

<masak> rakudo​: $/ = "abc"; say $1
<p6eval> rakudo 55f51d​: b␤
<masak> hihi.
* masak submits rakudobug
<pmichaud> rakudo​: my $a = 'abc'; say $a[1];
<p6eval> rakudo 55f51d​: Method 'postcircumfix​:[ ]' not found for
invocant of class 'Str' [...]
<pmichaud> heh
<pmichaud> interesting
<pmichaud> rakudo​: $/ = "abc"; say $/[1]
<p6eval> rakudo 55f51d​: Method 'postcircumfix​:[ ]' not found for
invocant of class 'Str' [...]
<pmichaud> oh, I get it.
<masak> pmichaud​: it's PIR semantics leaking through in exactly that case.
<pmichaud> masak++
<pmichaud> masak​: right.

new error​:

my $a = 'abc'; say $a[1];
===SORRY!===
.[1] out of range for type Str()

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Jul 28, 2010

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

@p6rt
Copy link
Author

p6rt commented Jul 28, 2010

From @pmichaud

new error​:

my $a = 'abc'; say $a[1];
===SORRY!===
.[1] out of range for type Str()

I believe this is the correct behavior per the specification.

Pm

@p6rt
Copy link
Author

p6rt commented Aug 19, 2010

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

@p6rt p6rt closed this as completed Aug 19, 2010
@p6rt
Copy link
Author

p6rt commented Aug 19, 2010

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S05-match/capturing-contexts.t

commit d82fd16f9c4f20066502717e4b5f50b76573c8de
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Thu Aug 19 19​:18​:36 2010 +0000

  [t/spec] tests for RT #​71362, $0, $1 etc. work even for $/ := $something
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;32059 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S05-match/capturing-contexts.t b/t/spec/S05-match/capturing-contexts.t
index d35c460..80c950e 100644
--- a/t/spec/S05-match/capturing-contexts.t
+++ b/t/spec/S05-match/capturing-contexts.t
@@ -106,6 +106,13 @@ is_run( q{'aa' ~~ /(.)$1/},
     is ($/.orig).rindex('a', 2), 1, 'rindex() works on $/.orig';
 }
 
+# RT #71362
+{
+    $/ := 'foobar';
+    is $0, 'foobar', '$0 works like $/[0], even for non-Match objects';
+    nok $1.defined, '$1 is not defined';
+}
+
 # RT #72956
 {
     $/ = Any;

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant