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

Indexing an attribute array with a Num causes MMD not to match in Rakudo #1777

Closed
p6rt opened this issue May 22, 2010 · 6 comments
Closed

Indexing an attribute array with a Num causes MMD not to match in Rakudo #1777

p6rt opened this issue May 22, 2010 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented May 22, 2010

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

Searchable as RT75266$

@p6rt
Copy link
Author

p6rt commented May 22, 2010

From @masak

<finanalyst> rakudo​: class A {has $.a; has @​.m; method foo { for $.a
.. 5 { say @​.m[$_] }}}; my A $x.=new(​:a(2.0),​:m(1,2,3,4,5));$x.foo
<p6eval> rakudo 9a15b8​: OUTPUT«No applicable candidates found to
dispatch to for 'postcircumfix​:<[ ]>'. Available candidates are​:␤​:(Mu
: Int $i;; *%_)␤​:(Mu : Block $b;; *%_)␤​:(Mu :
!whatever_dispatch_helper ;; *%_) [...]
<finanalyst> isBEKaml​: thats the error
<masak> rakudo​: class A { has @​.m; method foo { @​.m[2.0] } };
A.new(​:m(1,2,3)).foo
<p6eval> rakudo 9a15b8​: OUTPUT«No applicable candidates found to
dispatch to for 'postcircumfix​:<[ ]>'. Available candidates are​:␤​:(Mu
: Int $i;; *%_)␤​:(Mu : Block $b;; *%_)␤​:(Mu :
!whatever_dispatch_helper ;; *%_)␤ [...]
* masak submits rakudobug
<masak> finanalyst++
<masak> rakudo​: my @​m = 1,2,3; say @​m[2.0]
<p6eval> rakudo 9a15b8​: OUTPUT«3␤»
<finanalyst> masak​: somehow the type of the attribute is being
'imported' during the call to new
<masak> finanalyst​: you mean of $.a? but that's not it, my example
didn't use $.a
<isBEKaml> rakudo​: class A { has @​.m; method foo { @​.m[2] } };
A.new(​:m(1,2,3)).foo
<p6eval> rakudo 9a15b8​: ( no output )
<finanalyst> masak​: I ran across a bug where arrays inside a method
were being treated differently than outside. is this the same thing?
<finanalyst> we discussed it about two weeks ago
<colomon> finanalyst​: probably is the same thing.
<masak> rakudo​: class A { has @​.m; }; A.new(​:m(1,2,3)).m[2.0]
<p6eval> rakudo 9a15b8​: OUTPUT«No applicable candidates found to
dispatch to for 'postcircumfix​:<[ ]>'. Available candidates are​:␤​:(Mu
: Int $i;; *%_)␤​:(Mu : Block $b;; *%_)␤​:(Mu :
!whatever_dispatch_helper ;; *%_) [...]
<masak> it's not even methods.
<masak> it's just the attribute array.

@p6rt
Copy link
Author

p6rt commented Jun 20, 2010

From @jnthn

On Sat May 22 07​:47​:38 2010, masak wrote​:

<finanalyst> rakudo​: class A {has $.a; has @​.m; method foo { for $.a
.. 5 { say @​.m[$_] }}}; my A $x.=new(​:a(2.0),​:m(1,2,3,4,5));$x.foo
<p6eval> rakudo 9a15b8​: OUTPUT«No applicable candidates found to
dispatch to for 'postcircumfix​:<[ ]>'. Available candidates are​:␤​:(Mu
: Int $i;; *%_)␤​:(Mu : Block $b;; *%_)␤​:(Mu :
!whatever_dispatch_helper ;; *%_) [...]
<finanalyst> isBEKaml​: thats the error
<masak> rakudo​: class A { has @​.m; method foo { @​.m[2.0] } };
A.new(​:m(1,2,3)).foo
<p6eval> rakudo 9a15b8​: OUTPUT«No applicable candidates found to
dispatch to for 'postcircumfix​:<[ ]>'. Available candidates are​:␤​:(Mu
: Int $i;; *%_)␤​:(Mu : Block $b;; *%_)␤​:(Mu :
!whatever_dispatch_helper ;; *%_)␤ [...]
* masak submits rakudobug
<masak> finanalyst++
<masak> rakudo​: my @​m = 1,2,3; say @​m[2.0]
<p6eval> rakudo 9a15b8​: OUTPUT«3␤»
<finanalyst> masak​: somehow the type of the attribute is being
'imported' during the call to new
<masak> finanalyst​: you mean of $.a? but that's not it, my example
didn't use $.a
<isBEKaml> rakudo​: class A { has @​.m; method foo { @​.m[2] } };
A.new(​:m(1,2,3)).foo
<p6eval> rakudo 9a15b8​: ( no output )
<finanalyst> masak​: I ran across a bug where arrays inside a method
were being treated differently than outside. is this the same thing?
<finanalyst> we discussed it about two weeks ago
<colomon> finanalyst​: probably is the same thing.
<masak> rakudo​: class A { has @​.m; }; A.new(​:m(1,2,3)).m[2.0]
<p6eval> rakudo 9a15b8​: OUTPUT«No applicable candidates found to
dispatch to for 'postcircumfix​:<[ ]>'. Available candidates are​:␤​:(Mu
: Int $i;; *%_)␤​:(Mu : Block $b;; *%_)␤​:(Mu :
!whatever_dispatch_helper ;; *%_) [...]
<masak> it's not even methods.
<masak> it's just the attribute array.

Works now​:

15​:03 <@​jnthn> rakudo​: class A { has @​.m; }; say A.new(​:m(1,2,3)).m[2.0]
15​:03 < p6eval> rakudo ee7620​: OUTPUT«3␤»

Given to moritz++ for spectesting.

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented Jun 20, 2010

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

@p6rt
Copy link
Author

p6rt commented Jun 22, 2010

From @moritz

Now tested in t/spec/S12-attributes/instance.t.

Cheers,
Mority

@p6rt
Copy link
Author

p6rt commented Jun 22, 2010

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

@p6rt p6rt closed this as completed Jun 22, 2010
@p6rt
Copy link
Author

p6rt commented Jun 22, 2010

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S12-attributes/instance.t

commit 971afd72f736ddb18557b782d16146d783086214
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Tue Jun 22 20​:55​:24 2010 +0000

  [t/spec] test for RT #​75266, indexing array attributes with non-Ints
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;31413 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S12-attributes/instance.t b/t/spec/S12-attributes/instance.t
index f1e015e..dd5b9cf 100644
--- a/t/spec/S12-attributes/instance.t
+++ b/t/spec/S12-attributes/instance.t
@@ -2,7 +2,7 @@ use v6;
 
 use Test;
 
-plan 128;
+plan 129;
 
 =begin pod
 
@@ -337,6 +337,10 @@ is Foo7e.new.attr, 42, "default attribute value (1)";
     is $o.m0, 'a', '@.a[0] works';
     is $o.m1, 'b', '@.a[*-2] works';
     is $o.m2, 'c', '@.a[*-1] works';
+
+    # RT #75266
+    is ArrayAttribTest.new(a => <x y z>).a[2.0], 'z',
+        'Can index array attributes with non-integers';
 }
 
 {
@@ -573,4 +577,5 @@ is Foo7e.new.attr, 42, "default attribute value (1)";
     is TestMethodAll.new(a => 5).all, 5, 'Can call a method all()';
 }
 
+
 # vim: ft=perl6

@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