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

Cannot import a symbol from precomp if its namespace is occupied #6082

Open
p6rt opened this issue Feb 16, 2017 · 1 comment
Open

Cannot import a symbol from precomp if its namespace is occupied #6082

p6rt opened this issue Feb 16, 2017 · 1 comment

Comments

@p6rt
Copy link

p6rt commented Feb 16, 2017

Migrated from rt.perl.org#130794 (status was 'new')

Searchable as RT130794$

@p6rt
Copy link
Author

p6rt commented Feb 16, 2017

From @skids

If a module explicitly uses a symbol as a namespace, it cannot export a class or role as that symbol name.

$ cat > /tmp/f1.pm6
module f1 {
class A​::B { }
class A is export { }
}
$ PERL6LIB=/tmp perl6 -e "use f1"
===SORRY!=== Error while compiling -e
Cannot import symbol A from f1, because it already exists in this lexical scope
at -e​:1
------> use f1⏏<EOL>
$ cat > /tmp/f1.pm6
module f1 {
my $A​::B;
class A is export { }
}
$ PERL6LIB=/tmp perl6 -e "use f1"
===SORRY!=== Error while compiling -e
Cannot import symbol A from f1, because it already exists in this lexical scope
at -e​:1
------> use f1⏏<EOL>

This appears to be due to the namespace symbol being imported even though nothing in it exports...

$ cat /tmp/f1.pm6
module f1 {
my $A​::B = 42
}
$ PERL6LIB=/tmp perl6 -e "use f1; say :​:(A)"
Use of uninitialized value of type A in string context.
Methods .^name, .perl, .gist, or .say can be used to stringify it to something meaningful.
  in block <unit> at -e line 1
No such symbol ''
  in block <unit> at -e line 1

Actually thrown at​:
  in block <unit> at -e line 1

$ PERL6LIB=/tmp perl6 -e "say :​:(A)"
===SORRY!=== Error while compiling -e
Undeclared name​:
  A used at line 1

(I think this is a newish behavior but couldn't figure out how to get bisectable to handle a precomp)

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