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

$.bar getter method calls are always undefined inside a Str method in a class derived from Str in Rakudo #1319

Closed
p6rt opened this issue Sep 25, 2009 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Sep 25, 2009

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

Searchable as RT69378$

@p6rt
Copy link
Author

p6rt commented Sep 25, 2009

From @masak

<masak> rakudo​: class A { has $.bar = "OH HAI"; method Str() { $.bar }
}; say A.new.Str
<p6eval> rakudo 0eaf62​: OUTPUT«OH HAI␤»
<masak> rakudo​: class A is Str { has $.bar = "OH HAI"; method Str() {
$.bar } }; say A.new.Str
<p6eval> rakudo 0eaf62​: OUTPUT«Use of uninitialized value␤␤»
* masak reports rakudobug
<moritz_> masak​: why is that a bug?
<masak> moritz_​: because it calls the Str method, but the attribute is undef.
<moritz_> masak​: A.new ~~ Str, so I don't see why it should call
method Str at all
<masak> moritz_​: well, it does.
<masak> so either way, it's a bug.
<masak> moritz_​: actually, I'd argue that if you define your own .Str
method, and then call it, it should be called.
<masak> but it is, so that's no problem.
<moritz_> oh wait, you call it explicitly... yeah, sorry
<masak> np. it's a confusing bug.
<masak> the problem is that $.bar yields undef for some reason.

@p6rt
Copy link
Author

p6rt commented Oct 6, 2009

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S13-type-casting/methods.t

commit ed12a3d34d0f2b594d023d49b967273ea6d3e0e0
Author​: kyle <kyle@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Tue Oct 6 03​:31​:07 2009 +0000

  [t/spec] Test for RT #​69378
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;28636 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S13-type-casting/methods.t b/t/spec/S13-type-casting/methods.t
index e15a7f1..8144e48 100644
--- a/t/spec/S13-type-casting/methods.t
+++ b/t/spec/S13-type-casting/methods.t
@@ -1,6 +1,6 @@
 use v6;
 use Test;
-plan 2;
+plan 4;
 
 # L<S13/Type Casting/"whose name is a declared type, it is taken as a coercion
 # to that type">
@@ -14,4 +14,20 @@ my $o = CoercionTest.new();
 is ~$o, 'foo', 'method Str takes care of correct stringification';
 ok +$o == 1.2, 'method Num takes care of correct numification';
 
+# RT #69378
+{
+    class RT69378 {
+        has $.x = 'working';
+        method Str() { $.x }
+    }
+    is RT69378.new.Str, 'working', 'call to .Str works';
+
+    class RT69378str is Str {
+        has $.a = 'RT #69378';
+        method Str() { $.a }
+    }
+    #?rakudo todo 'RT 69378'
+    is RT69378str.new.Str, 'RT #69378', 'call to .Str works on "class is Str"';
+}
+
 # vim: ft=perl6

@p6rt
Copy link
Author

p6rt commented Oct 6, 2009

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

@p6rt
Copy link
Author

p6rt commented Jun 26, 2010

From @moritz

Tests now pass; closing ticket.

@p6rt
Copy link
Author

p6rt commented Jun 26, 2010

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

@p6rt p6rt closed this as completed Jun 26, 2010
@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