Skip Menu |

This queue is for tickets about the Marpa-R2 CPAN distribution.

Report information
The Basics
Id: 81340
Status: resolved
Priority: 0/
Queue: Marpa-R2

People
Owner: jkegl [...] cpan.org
Requestors: Support [...] RoxSoft.co.uk
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.024000
Fixed in: (no value)



Subject: Unimported variable - state feature not enabled
Running on Perl 5.10.1 I get this error Variable "$stuifzand_grammar" is not imported at /usr/local/lib/perl/5.10.1/Marpa/R2/Stuifzand.pm line 349, <DATA> line 1. Oddly I do not get this error when running the tests for the parser that I wrote using Marpa:R2. The error only appears when using the parser class in a DBIx::Class::ResultSet. The cause was that the state feature had not been enabled. Adding use feature qw( state ); to Stuifzand.pm fixes the problem. Patch attached
Subject: Stuifzand.diff
--- Stuifzand.pm 2012-11-22 10:38:39.000000000 +0000 +++ Stuifzand.pm 2012-11-22 10:39:01.000000000 +0000 @@ -28,6 +28,8 @@ package Marpa::R2::Internal::Stuifzand; +use feature qw( state ); + use English qw( -no_match_vars ); # Undo any rewrite of the symbol name
Thanks for your interest, your work on this and for providing a patch. Before taking it upstream, I want to clarify the issues. Stuifzand.pm already has "use 5.010" which, according to the doc (http://perldoc.perl.org/feature.html), brings in a feature bundle including "state". And "state" would not be working elsewhere (which it seems to be) unless this was happening. As you point out, it also works sometimes on your setup. So I wonder if there is not really some issue with that setup, or perhaps something wierd with DBIx::Class::ResultSet? -- jeffrey On Thu Nov 22 05:58:29 2012, PJFL wrote: Show quoted text
> Running on Perl 5.10.1 I get this error > > Variable "$stuifzand_grammar" is not imported at > /usr/local/lib/perl/5.10.1/Marpa/R2/Stuifzand.pm line 349, <DATA> line 1. > > Oddly I do not get this error when running the tests for the parser that > I wrote using Marpa:R2. The error only appears when using the parser > class in a DBIx::Class::ResultSet. > > The cause was that the state feature had not been enabled. Adding > > use feature qw( state ); > > to Stuifzand.pm fixes the problem. Patch attached
On Thu Nov 22 19:13:53 2012, JKEGL wrote: Show quoted text
> Stuifzand.pm already has "use 5.010" which, according to the doc > (http://perldoc.perl.org/feature.html), brings in a feature bundle > including "state".
From the same document: "Like other pragmas (use strict , for example), features have a lexical effect. use feature qw(foo) will only make the feature "foo" available from that point to the end of the enclosing block." The use 5.010 is in Marpa::R2::Stuifzand not in Marpa::R2::Internal::Stuifzand, so the state feature shouldn't be in scope. I think that the real question here is why does it work most of the time? I'm thinking that it currently works by exploiting a bug in Perl whereby the enabling of the state feature is happening by accident, some king of scope leakage perhaps? Regards
I believe that the lexical effect by design crosses package declarations, which are not considered to end blocks. The doc explicitly compares features with "use strict;", so let's try this experiment: package My_Package; use strict; $a = $undeclared; package My_Other_Package; $b = $undeclared_1; The result is Global symbol "$undeclared" requires explicit package name at test.pl line 4. Global symbol "$undeclared_1" requires explicit package name at test.pl line 6. that is, "strict" stays in effect across the "package My_Other_Package;". And if you comment out the "use strict;", both error messages are silenced. My understanding is that this is not scope leakage, but the scopes behaving as documented and designed. Does that make sense? On Thu Nov 22 23:10:54 2012, PJFL wrote: Show quoted text
> On Thu Nov 22 19:13:53 2012, JKEGL wrote:
> > Stuifzand.pm already has "use 5.010" which, according to the doc > > (http://perldoc.perl.org/feature.html), brings in a feature bundle > > including "state".
> > From the same document: > > "Like other pragmas (use strict , for example), features have a > lexical effect. use feature qw(foo) will only make the feature "foo" > available from that point to the end of the enclosing block." > > The use 5.010 is in Marpa::R2::Stuifzand not in > Marpa::R2::Internal::Stuifzand, so the state feature shouldn't be in > scope. I think that the real question here is why does it work most of > the time? I'm thinking that it currently works by exploiting a bug in > Perl whereby the enabling of the state feature is happening by accident, > some king of scope leakage perhaps? > > Regards
On Thu Nov 22 23:45:54 2012, JKEGL wrote: Show quoted text
> Does that make sense?
Yes. Much more sense than my previous post.
Digging further I've discovered that the problem goes away if I remove no bareword::filehandles; no multidimensional; from my custom Moose exporter, which is strange. Many thanks for Marpa::R2, the little expression evaluator that I've written is delightful. Regards