You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the documentation I expect the func keyword to work like this:
perl -e 'use perl5i::2; func test($t) { return $t } print test("test")'
This gives the following error message:
PL_linestr not long enough, was Devel::Declare loaded soon enough in -e at /home/user/perl5/perls/perl-5.16.2/lib/site_perl/5.16.2/x86_64-linux/Devel/Declare/Context/Simple.pm line 71.
When I use the perl5i binary instead of perl like this:
perl5i -e'use perl5i::2; func test($t) { return $t } print test("test")'
I get
Prototype mismatch: sub main::open (*;$@) vs none at /home/user/perl5/perls/perl-5.16.2/lib/site_perl/5.16.2/perl5i/2/UNIVERSAL.pm line 23
test
Only when I use perl5i and remove the "use perli5::2" inside it works as expected.
The text was updated successfully, but these errors were encountered:
The PL_linestr error is an unfortunate bug in Devel::Declare which perl5i uses to rewrite Perl syntax. The same problem appears in related modules like Method::Signatures or MooseX::Method::Signatures.
$ perl -e 'use MooseX::Method::Signatures; method test($t) { return $t } print main->test("test")'
PL_linestr not long enough, was Devel::Declare loaded soon enough in -e at /Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/darwin-thread-multi-2level/Devel/Declare/Context/Simple.pm line 71.
$ perl -e 'use Method::Signatures; method test($t) { return $t } print main->test("test")'
PL_linestr not long enough, was Devel::Declare loaded soon enough in -e at /Users/schwern/perl5/perlbrew/perls/perl-5.16.2-threads/lib/site_perl/5.16.2/darwin-thread-multi-2level/Devel/Declare/Context/Simple.pm line 71.
perl5i -e'use perl5i::2; is throwing a warning because it's effectively importing perl5i into the same namespace twice. That could probably be prevented.
perl -Mperl5i::2 -e works, I think, because Devel::Declare is loaded before Perl sees the -e line and has time to do its magic. The perl5i binary should be doing the equivalent of perl -Mperl5i::2 -e so it should work... and it does.
I see two actions out of this...
Document the perl -e 'use perl5i::2; ...' limitations and the perl5i -e and perl -Mperl5i::2 -e work arounds.
Allow loading perl5i::2 multiple times in the same namespace without warning.
According to the documentation I expect the func keyword to work like this:
perl -e 'use perl5i::2; func test($t) { return $t } print test("test")'
This gives the following error message:
PL_linestr not long enough, was Devel::Declare loaded soon enough in -e at /home/user/perl5/perls/perl-5.16.2/lib/site_perl/5.16.2/x86_64-linux/Devel/Declare/Context/Simple.pm line 71.
When I use the perl5i binary instead of perl like this:
perl5i -e'use perl5i::2; func test($t) { return $t } print test("test")'
I get
Prototype mismatch: sub main::open (*;$@) vs none at /home/user/perl5/perls/perl-5.16.2/lib/site_perl/5.16.2/perl5i/2/UNIVERSAL.pm line 23
test
Only when I use perl5i and remove the "use perli5::2" inside it works as expected.
The text was updated successfully, but these errors were encountered: