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

Problem when used in a module that is subsequently required #30

Closed
jonathanstowe opened this issue Oct 23, 2016 · 0 comments · Fixed by #31
Closed

Problem when used in a module that is subsequently required #30

jonathanstowe opened this issue Oct 23, 2016 · 0 comments · Fixed by #31

Comments

@jonathanstowe
Copy link
Member

I found this when trying to 'require LWP::Simple' and then use it's methods:

Cannot invoke this object (REPR: Null; VMNull)
  in sub scheme-port at /home/jonathan/.rakudobrew/moar-nom/install/share/perl6/site/sources/07EE6C07F38281215C37955BB3BC16CFA9604F8E (URI::DefaultPort) line 36
  in method default-port at /home/jonathan/.rakudobrew/moar-nom/install/share/perl6/site/sources/E6932313C3FA27F20E3F940809AFC1198E0EC2E5 (URI) line 150
  in method port at /home/jonathan/.rakudobrew/moar-nom/install/share/perl6/site/sources/E6932313C3FA27F20E3F940809AFC1198E0EC2E5 (URI) line 162
  in method parse_url at /home/jonathan/.rakudobrew/moar-nom/install/share/perl6/site/sources/2A99795C71C31D3D9A9D39DCFC0379F0F4CDEDC5 (LWP::Simple) line 365
  in method request_shell at /home/jonathan/.rakudobrew/moar-nom/install/share/perl6/site/sources/2A99795C71C31D3D9A9D39DCFC0379F0F4CDEDC5 (LWP::Simple) line 58
  in method get at /home/jonathan/.rakudobrew/moar-nom/install/share/perl6/site/sources/2A99795C71C31D3D9A9D39DCFC0379F0F4CDEDC5 (LWP::Simple) line 31
  in method getstore at /home/jonathan/.rakudobrew/moar-nom/install/share/perl6/site/sources/2A99795C71C31D3D9A9D39DCFC0379F0F4CDEDC5 (LWP::Simple) line 344
  in block <unit> at tt line 3

where ``tt` is

try require LWP::Simple;

say ::('LWP::Simple').getstore('http://rabidgravy.com/index.html', 'test');

Though it can be reqplicated with a module:

use URI;

class TestURIRequire {
    method test(Str $uri) {
        my $u = URI.new($uri);
        $u.port;
    }
}

And testing it with

use Test;
plan 2;

require TestURIRequire;

my $port;

lives-ok { $port = ::("TestURIRequire").test('http://example.com'); }, "can use URI in a module that is itself required rather than used";
is $port, 80, "and got the right thing back";

Which is all a bit upsetting.

I am working on a fix at the moment.

jonathanstowe added a commit to jonathanstowe/uri that referenced this issue Oct 23, 2016
By making URI::DefaultPort a class and default-port a method
it overcomes the problem when URI is used in a module which
is subsequently 'require'd

Fixes raku-community-modules#30
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

Successfully merging a pull request may close this issue.

1 participant