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

Map instead of Hash from sub EXPORT results in missing error about non-dynamics via CALLER:: #1372

Open
zoffixznet opened this issue Jan 6, 2018 · 2 comments

Comments

@zoffixznet
Copy link
Contributor

zoffixznet commented Jan 6, 2018

I believe the first eval needs to throw just like the second does:

<Zoffix__> m: BEGIN '/tmp/dyncall'.IO.mkdir.add('DYN.pm6').spurt: 「sub EXPORT { Map.new: ('$meows' => 'foos', '&foo' => sub { CALLER::<$meows> }) }」; use lib </tmp/dyncall>; use DYN; say foo
<camelia> rakudo-moar 6a6470f9d: OUTPUT: «foos␤»

<Zoffix__> m: BEGIN '/tmp/dyncall'.IO.mkdir.add('DYN.pm6').spurt: 「sub EXPORT { {'$meows' => 'foos', '&foo' => sub { CALLER::<$meows> }} }」; use lib </tmp/dyncall>; use DYN; say foo
<camelia> rakudo-moar 6a6470f9d: OUTPUT: «Cannot access '$meows' through CALLER, because it is not declared as dynamic␤  in sub  at /tmp/dyncall/DYN.pm6 (DYN) line 1␤  in block <unit> at <tmp> line 1␤␤»
@jnthn
Copy link
Member

jnthn commented Jan 6, 2018

I think the problem here is that dynamic is presently a property on a Scalar (or Array or Hash). When CALLER lookups encounter something that does not have a dynamic method, it just resolves the result. We can't just make that case throw, alas, because we'd break every case like my $*FOO := 42 - that is, where binding was used.

@jnthn
Copy link
Member

jnthn commented Jan 6, 2018

Also, to be clear, I'm not saying this shouldn't be fixed, just that there's not an immediately obvious way to do it.

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

2 participants