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

Can't find &say inside method that came from a role in Rakudo #1666

Closed
p6rt opened this issue Apr 5, 2010 · 9 comments
Closed

Can't find &say inside method that came from a role in Rakudo #1666

p6rt opened this issue Apr 5, 2010 · 9 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Apr 5, 2010

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

Searchable as RT74078$

@p6rt
Copy link
Author

p6rt commented Apr 5, 2010

From @masak

<colomon> rakudo​: role Animal { method speak() { say "Blah"; } }; role
Canine does Animal { method speak() { say "Howl"; }}; class Dog does
Canine { }; Dog.new.speak
<p6eval> rakudo c41cf3​: OUTPUT«Could not find sub &say [...]
<colomon> :\
<masak> colomon​: that seems wrong.
<colomon> masak​: my code or Rakudo's response?
<masak> colomon​: Rakudo's not finding &say.
<masak> colomon​: perhaps a result of jnthn's refactors today.
<colomon> rakudo​: role Animal { method speak() { say "Blah"; } };
class Dog does Animal { }; Dog.new.speak
<p6eval> rakudo c41cf3​: OUTPUT«Could not find sub &say [...]
<colomon> masak​: I was actually trying to duplicate the bug I got
working on Numeric / Real a few days ago.
<colomon> I seem to have found an entirely different bug in the process.
<masak> colomon++
<masak> rakudo​: class Dog { method speak() { say "Blah"; } }; Dog.new.speak
<p6eval> rakudo c41cf3​: OUTPUT«Blahâ�¤Â»
<masak> colomon​: care to submit it to RT? or shall I?
<colomon> be my guest, I need to get back to packing. ;)
* masak submits

@p6rt
Copy link
Author

p6rt commented Apr 25, 2010

From @masak

<takadonet> rakudo​: role work { method x {say 'hello'}}; class me does work {}; me.new.x();
<p6eval> rakudo e393c7​: OUTPUT«Could not find sub &say [...]
<takadonet> Is there a work around that?
<takadonet> It's already reported as a bug
<masak> takadonet​: 'fraid the workaround is not to use roles... :(
<takadonet> masak​: not the answer I was looking for :(
<masak> takadonet​: I understand that. let me know if you find a better answer. :/
<masak> rakudo​: our &s = &say; role A { method foo { &s("OH HAI") } }; class B does A {};
B.new.foo
<p6eval> rakudo e393c7​: OUTPUT«OH HAIâ�¤Â»
<masak> takadonet​: that seems to work.
<takadonet> masak​: thanks!
* masak adds that to the ticket

@p6rt
Copy link
Author

p6rt commented Apr 25, 2010

From [Unknown Contact. See original ticket]

<takadonet> rakudo​: role work { method x {say 'hello'}}; class me does work {}; me.new.x();
<p6eval> rakudo e393c7​: OUTPUT«Could not find sub &say [...]
<takadonet> Is there a work around that?
<takadonet> It's already reported as a bug
<masak> takadonet​: 'fraid the workaround is not to use roles... :(
<takadonet> masak​: not the answer I was looking for :(
<masak> takadonet​: I understand that. let me know if you find a better answer. :/
<masak> rakudo​: our &s = &say; role A { method foo { &s("OH HAI") } }; class B does A {};
B.new.foo
<p6eval> rakudo e393c7​: OUTPUT«OH HAIâ�¤Â»
<masak> takadonet​: that seems to work.
<takadonet> masak​: thanks!
* masak adds that to the ticket

@p6rt
Copy link
Author

p6rt commented Apr 25, 2010

@masak - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented May 3, 2010

From albastev@yahoo.com

Hello,

I hope you have had a good weekend.  I had just downloaded the April development release, and was experimenting with Perl 6 classes when I found that I could not use the 'say' subroutine from within a method declared in a role.  I found this as bug #​74078. 

I then tried several other built in functions, and they suffered similar fates.  I did not immediately find any tickets that matched the others, though I could have missed. I have included some example code below.

Hopefully this is helpful.   Even if it is not, I would like to thank you for your efforts.  Have a good week.

Steven Albano
use v6;

our &s = &say;
our &p = &print;
our &o = &open;
our &sl = &sleep;

role Howdy {
  method sayHowdy {
    # say 'Howdy!'; # does not work
    # print "Howdy!\n"; # does not work
    p "Howdy!\n"; # works
    # s 'Howdy!'; # works
    # my $file = open('hello.p6'); # does not work
    my $file = o('hello.p6'); # works
    # sleep(1); # does not work
    sl(1);
  }
}

class Greet does Howdy {
  method sayHi {
    say 'Hi!';
    # print "Hi!\n"; # works
    # my $file = open('hello.p6'); # works
    #sleep(1); #works
  }
}
#my $file = open('hello.p6'); # works
my $nod  = Greet.new();
#sleep(1); # works

$nod.sayHowdy();

 

@p6rt
Copy link
Author

p6rt commented Jul 3, 2010

From @supernovus

If you have a class that uses a role that defines an attribute, and you try
to augment it later, currently in Rakudo, bad things happen.

role F { has Int $.boo = 1 }
class B does F {}

use MONKEY_TYPING;
augment class B {
  method hi { say 'hi' }
}

# Attribute '$!boo' already exists in the class, but a role also wishes to
compose it

my $b = B.new; $b.hi;

# Could not find sub &say

Very strange behavior indeed. I found it while extracting DateTime​::strftime
out of Core and into a loadable module.

@p6rt
Copy link
Author

p6rt commented Jul 12, 2010

From @bbkr

WORKS​:
$ perl6 -e 'role Foo { method foo {666.say;}; }; class A does Foo {};
A.new.foo'
666

FAILS​:
$ perl6 -e 'role Foo { method foo {say 666;}; }; class A does Foo {};
A.new.foo'
Could not find sub &say
  in 'foo' at line 1
  in main program body at line 1

@p6rt
Copy link
Author

p6rt commented Oct 1, 2011

From @moritz

works now in rakudo, and tested in t/spec/S14-roles/composition.t.

@p6rt
Copy link
Author

p6rt commented Oct 1, 2011

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

@p6rt p6rt closed this as completed Oct 1, 2011
@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