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 augment class Int #1763

Closed
p6rt opened this issue May 15, 2010 · 11 comments
Closed

Can't augment class Int #1763

p6rt opened this issue May 15, 2010 · 11 comments

Comments

@p6rt
Copy link

p6rt commented May 15, 2010

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

Searchable as RT75114$

@p6rt
Copy link
Author

p6rt commented May 15, 2010

From @moritz

<@​moritz_> rakudo​: use MONKEY_TYPING; augment class Int { method foo {
say "OH HAI" } }; 5.foo
<+p6eval> rakudo ddaab3​: OUTPUT«Method 'foo' not found for invocant of
class 'Integer'␤current instr.​: '_block14' pc 29 (EVAL_1​:0)␤»

There are two bugs in here; the first being that method foo is not
found, and the second is that it reports class Integer, even though that
doesn't exist​:

<@​moritz_> rakudo​: use MONKEY_TYPING; augment class Integer { method foo
  { say "OH HAI" } }; 5.foo
<+p6eval> rakudo ddaab3​: OUTPUT«Can't augment class that doesn't
exist␤current instr.​: 'perl6;Perl6;Grammar;add_name' pc 43094
(src/gen/perl6-grammar.pir​:344)␤»

@p6rt
Copy link
Author

p6rt commented May 15, 2010

From @zhuomingliang

在 2010-05-15 01​:24​:44 星期六 时,moritz 写到:

<@​moritz_> rakudo​: use MONKEY_TYPING; augment class Int { method foo {
say "OH HAI" } }; 5.foo
<+p6eval> rakudo ddaab3​: OUTPUT«Method 'foo' not found for invocant of
class 'Integer'␤current instr.​: '_block14' pc 29 (EVAL_1​:0)␤»

There are two bugs in here; the first being that method foo is not
found, and the second is that it reports class Integer, even though that
doesn't exist​:

<@​moritz_> rakudo​: use MONKEY_TYPING; augment class Integer { method foo
{ say "OH HAI" } }; 5.foo
<+p6eval> rakudo ddaab3​: OUTPUT«Can't augment class that doesn't
exist␤current instr.​: 'perl6;Perl6;Grammar;add_name' pc 43094
(src/gen/perl6-grammar.pir​:344)␤»

rakudo​: use MONKEY_TYPING; augment class Str { method Yes() { 'yes,
please'; } }; 'No'.Yes().say;
<p6eval>rakudo ddaab3​: OUTPUT«Method 'Yes' not found for invocant of
class 'Perl6Str'␤current instr.​: '_block14' pc 29 (EVAL_1​:0)␤»

@p6rt
Copy link
Author

p6rt commented May 15, 2010

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

@p6rt
Copy link
Author

p6rt commented May 16, 2010

From @zhuomingliang

Inline Patch
diff --git a/src/Perl6/Actions.pm b/src/Perl6/Actions.pm
index 9c7f936..2e60137 100644
--- a/src/Perl6/Actions.pm
+++ b/src/Perl6/Actions.pm
@@ -2297,7 +2297,7 @@ method number:sym<numish>($/) {
 }
 
 method numish($/) {
-    if $<integer> { make PAST::Val.new( :value($<integer>.ast) ); }
+    if $<integer> { make PAST::Val.new( :value($<integer>.ast),
:returns('Int') ); }   elsif $\ \{ make $\\.ast; \}   elsif $\ \{ make $\\.ast; \}   else \{ @​@​ \-2510,7 \+2510,7 @​@​ method quote\_EXPR\($/\) \{   $past := PAST​::Stmts\.new\($past\);   \}   else \{ \- $past := PAST​::Val\.new\(​:value\(~@​words\[0\]\), :returns\\); \+ $past := PAST​::Val\.new\( :value\(~@​words\[0\]\), :returns\('Str'\) \);   \}   \}   \}

@p6rt
Copy link
Author

p6rt commented May 16, 2010

From @zhuomingliang

upload the patch

@p6rt
Copy link
Author

p6rt commented May 16, 2010

From @zhuomingliang

0001-fixed-75114-Can-t-augment-class-Int.patch
From 0c1b724f8b9d42403218d2aadd8037db2c79c8f5 Mon Sep 17 00:00:00 2001
From: Jimmy Zhuo <zhuomingliang@yahoo.com.cn>
Date: Sun, 16 May 2010 19:08:51 +0800
Subject: [PATCH] fixed #75114: Can't augment class Int

---
 src/Perl6/Actions.pm |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/Perl6/Actions.pm b/src/Perl6/Actions.pm
index 9c7f936..2e60137 100644
--- a/src/Perl6/Actions.pm
+++ b/src/Perl6/Actions.pm
@@ -2297,7 +2297,7 @@ method number:sym<numish>($/) {
 }
 
 method numish($/) {
-    if $<integer> { make PAST::Val.new( :value($<integer>.ast) ); }
+    if $<integer> { make PAST::Val.new( :value($<integer>.ast), :returns('Int') ); }
     elsif $<dec_number> { make $<dec_number>.ast; }
     elsif $<rad_number> { make $<rad_number>.ast; }
     else {
@@ -2510,7 +2510,7 @@ method quote_EXPR($/) {
                 $past := PAST::Stmts.new($past);
             }
             else {
-                $past := PAST::Val.new(:value(~@words[0]), :returns<Str>);
+                $past := PAST::Val.new( :value(~@words[0]), :returns('Str') );
             }
         }
     }
-- 
1.7.0.4

@p6rt
Copy link
Author

p6rt commented Jun 3, 2010

From @moritz

I've applied the patch, thank you Jimmy!

It does solve the problem in some cases, but not in others.

There's a test in t/spec/S04-statements/for.t that still fails (fudged
at the moment).

@p6rt
Copy link
Author

p6rt commented Jun 4, 2010

From @zhuomingliang

在 2010-06-03 12​:37​:50 星期四 时,moritz 写到:

I've applied the patch, thank you Jimmy!

It does solve the problem in some cases, but not in others.

There's a test in t/spec/S04-statements/for.t that still fails (fudged
at the moment).

#?rakudo skip 'class accessing outer lexical'
{
  my $d = '';
  augment class Int {
  method some_meth_1 {
  $d = $d ~ self
  }
  };
  for 0 .. 5 { .some_meth_1 };
  is($d, '012345', 'for 0 .. 5 { .some_sub } works');
}

It doesn't work, yeah, and So this one​:

my $d = '';
augment class Str {
  method some_meth_1 {
  $d = $d ~ self;
  }
};

for '0' .. '5' { .some_meth_1 };

@p6rt
Copy link
Author

p6rt commented Jun 4, 2010

From @zhuomingliang

在 2010-06-03 12​:37​:50 星期四 时,moritz 写到:

I've applied the patch, thank you Jimmy!

It does solve the problem in some cases, but not in others.

There's a test in t/spec/S04-statements/for.t that still fails (fudged
at the moment).

Yep, and

use MONKEY_TYPING;
my $d = '';
augment class Str {
  method some_meth_1 {
  $d = $d ~ self;
  }
};

for '0' .. '5' { .some_meth_1 };

Doesn't work.

@p6rt
Copy link
Author

p6rt commented Jan 22, 2011

From @felliott

Hello,

This seems to be working now and has tests in S12-class/open.t. The
failing test in for.t was failing due to a bug in Range, not because of
the for or the augment class Int. The Range bug has been reported as RT
#​82620. I'm marking this resolved.

Cheers,
Fitz

@p6rt
Copy link
Author

p6rt commented Jan 22, 2011

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

@p6rt p6rt closed this as completed Jan 22, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant