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

Presence of a DBIish.connect call in an INIT block in a module causes exports not to work from the module in Rakudo #3632

Open
p6rt opened this issue Jan 4, 2015 · 3 comments

Comments

@p6rt
Copy link

p6rt commented Jan 4, 2015

Migrated from rt.perl.org#123541 (status was 'open')

Searchable as RT123541$

@p6rt
Copy link
Author

p6rt commented Jan 4, 2015

From @masak

$ perl6 -v
This is perl6 version 2014.12-86-g43b724e built on MoarVM version 2014.12

$ cat M.pm
use v6;
use DBIish;

module M {
  INIT { # A
  DBIish.connect("SQLite", :database<db>, :RaiseError); # B
  } # A

  our sub x() is export {
  say "OH HAI";
  }
}

$ perl6 -I. -e'use M; x()'
===SORRY!=== Error while compiling -e
Undeclared routine​:
  x used at line 1

...

This is not what I expected. I expected it to print "OH HAI".

Furthermore, remove the two lines marked "A", and it works as
expected. Remove the line marked "B" and it works.

My best guess, for what it's worth, is that the method call in the
INIT block is interfering with the normal exporting from the module.

@p6rt
Copy link
Author

p6rt commented Jan 4, 2015

From @lizmat

On 04 Jan 2015, at 14​:47, Carl Mäsak (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by "Carl Mäsak"
# Please include the string​: [perl #​123541]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=123541 >

$ perl6 -v
This is perl6 version 2014.12-86-g43b724e built on MoarVM version 2014.12

$ cat M.pm
use v6;
use DBIish;

module M {
INIT { # A
DBIish.connect("SQLite", :database<db>, :RaiseError); # B
} # A

our sub x() is export {
say "OH HAI";
}
}

$ perl6 -I. -e'use M; x()'
===SORRY!=== Error while compiling -e
Undeclared routine​:
x used at line 1

...

This is not what I expected. I expected it to print "OH HAI".

Furthermore, remove the two lines marked "A", and it works as
expected. Remove the line marked "B" and it works.

My best guess, for what it's worth, is that the method call in the
INIT block is interfering with the normal exporting from the module.

use v6;
use Test;
module M {
  INIT {
  say <a b c>.Set;
  }

  our sub x is export { say "x" }
}

This works without any problem.

I would concur that it is not just any method call, but something specific to DBIish.connect;

Liz

@p6rt
Copy link
Author

p6rt commented Jan 4, 2015

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

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