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

BUG: Loading Test.pm prevents augmented methods from being accessible as subs. #2260

Closed
p6rt opened this issue Nov 16, 2010 · 6 comments
Closed

Comments

@p6rt
Copy link

p6rt commented Nov 16, 2010

Migrated from rt.perl.org#79242 (status was 'rejected')

Searchable as RT79242$

@p6rt
Copy link
Author

p6rt commented Nov 16, 2010

From @thundergnat

use Test; # remove this line, and it works
use MONKEY_TYPING;

augment class Any {
  method foo is export { say "OH HAI" };
}

().foo; # Works whether or not Test is loaded
foo([]); # Doesn't work if Test is loaded

With Test loaded​:
OH HAI
Could not find sub &foo
  in main program body at line 9​:test.pl

Without Test loaded​:
OH HAI
OH HAI

Tested under Rakudo Star 2010.10; WinXP and Ubuntu Linux 10.10.

@p6rt
Copy link
Author

p6rt commented Nov 16, 2010

From @thundergnat

Some further information​: if the MONKEY_TYPING augment occurs in a
module that gets loaded BEFORE Test, the the augmented methods are
callable as subs. If Test is loaded first, the methods are not callable
as subs.

@p6rt
Copy link
Author

p6rt commented Nov 16, 2010

From @thundergnat

On Mon Nov 15 17​:26​:42 2010, thundergnat@​comcast.net wrote​:

use Test; # remove this line, and it works
use MONKEY_TYPING;

augment class Any {
method foo is export { say "OH HAI" };
}

().foo; # Works whether or not Test is loaded
foo([]); # Doesn't work if Test is loaded

With Test loaded​:
OH HAI
Could not find sub &foo
in main program body at line 9​:test.pl

Without Test loaded​:
OH HAI
OH HAI

Tested under Rakudo Star 2010.10; WinXP and Ubuntu Linux 10.10.

OK, the Test.pm module is a red herring. I get the same behavior if I
try the above test script with pretty much ANY module in the R* distro
library replacing Test.

use YAML; # fail
use Form; # fail
use Digest​::MD5; #fail

I even put a Bar.pm in my user lib directory that only contained the line​:

module Bar;

and got the same results.

Removing the "is export" from the method will trigger the same behavior
WITHOUT loading any other module

#############################################
use MONKEY_TYPING;

augment class Any {
method foo { say "OH HAI" };
}

().foo; # Works
foo([]); # Doesn't work

#############################################
returns​:
OH HAI
Could not find sub &foo
  in main program body at line 8​:any.p6

so it seems like loading a module interferes with the 'is export'
declaration somehow.

@p6rt
Copy link
Author

p6rt commented Feb 9, 2015

From @Mouq

Rakudo now consistently and correctly fails in *both* cases​:

$ perl6 -e'use MONKEY_TYPING; augment class Any { method foo is export { say "OH HAI" }; };().foo;foo([]);'
===SORRY!=== Error while compiling -e
Undeclared routine​:
  foo used at line 1

$ perl6 -e'use Test; use MONKEY_TYPING; augment class Any { method foo is export { say "OH HAI" }; };().foo;foo([]);'
===SORRY!=== Error while compiling -e
Undeclared routine​:
  foo used at line 1

Even though the output has become consistent, the spec of the behavior the ticket depends on has changed as well. Thus I'm marking this ticket as rejected.

On Tue Nov 16 12​:57​:46 2010, thundergnat wrote​:

On Mon Nov 15 17​:26​:42 2010, thundergnat@​comcast.net wrote​:

use Test; # remove this line, and it works
use MONKEY_TYPING;

augment class Any {
method foo is export { say "OH HAI" };
}

().foo; # Works whether or not Test is loaded
foo([]); # Doesn't work if Test is loaded

With Test loaded​:
OH HAI
Could not find sub &foo
in main program body at line 9​:test.pl

Without Test loaded​:
OH HAI
OH HAI

Tested under Rakudo Star 2010.10; WinXP and Ubuntu Linux 10.10.

OK, the Test.pm module is a red herring. I get the same behavior if I
try the above test script with pretty much ANY module in the R* distro
library replacing Test.

use YAML; # fail
use Form; # fail
use Digest​::MD5; #fail

I even put a Bar.pm in my user lib directory that only contained the line​:

module Bar;

and got the same results.

Removing the "is export" from the method will trigger the same behavior
WITHOUT loading any other module

#############################################
use MONKEY_TYPING;

augment class Any {
method foo { say "OH HAI" };
}

().foo; # Works
foo([]); # Doesn't work

#############################################
returns​:
OH HAI
Could not find sub &foo
in main program body at line 8​:any.p6

so it seems like loading a module interferes with the 'is export'
declaration somehow.

@p6rt
Copy link
Author

p6rt commented Feb 9, 2015

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

@p6rt
Copy link
Author

p6rt commented Feb 9, 2015

@Mouq - Status changed from 'open' to 'rejected'

@p6rt p6rt closed this as completed Feb 9, 2015
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