Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

namespace::clean and "Unknown Error"

by jasonk (Parson)
on Feb 16, 2009 at 18:41 UTC ( [id://744169]=perlquestion: print w/replies, xml ) Need Help??

jasonk has asked for the wisdom of the Perl Monks concerning the following question:

I've been having a lot of problems lately with "Unknown Error" getting reported rather than the actual error message. Since it started at roughly the time I upgraded to 5.10, I figured it was some strange 5.10/OS X issue, and since it was occurring in a project that has a gigantic code base, it took me a while to track it down. Turns out it's actually something related to namespace::clean that is causing the problem.

I've managed to narrow it down to this minimal test case, but I haven't had any luck in figuring out why this is occuring...

package Test1; use namespace::clean; sub foo { if } # Yes, this is an intentional syntax error 1;

I'm simply running this code from the command line like so:

% perl -Ilib -MTest1 -e1

If you remove the call to 'use namespace::clean', this is the output (which is what I would expect)

syntax error at lib/Test1.pm line 2, near "if }" Compilation failed in require. BEGIN failed--compilation aborted.

However, when using namespace::clean, the output becomes:

Unknown error Compilation failed in require. BEGIN failed--compilation aborted.

Obviously this makes it very difficult to find bugs when it isn't even reporting which file the error was in when loading up hundreds of modules for a very large application. I realize namespace::clean is doing some pretty heavy magic, but I'd hate to give it up considering how tremendously useful it is.

Update:

Reported it to RT (43362). I also forked it on github and added a testcase (http://github.com/jasonk/namespace-clean).


www.jasonkohles.com
We're not surrounded, we're in a target-rich environment!

Replies are listed 'Best First'.
Re: namespace::clean and "Unknown Error" (non-glob globals)
by tye (Sage) on Feb 17, 2009 at 16:33 UTC

    5.10 broke just about any code written prior that looks into a package's namespace. That seems likely to be part of the problem here.

    For the sake of saving memory, 5.10 causes code that expects (as has always been the case) for package symbol tables to only contain 'globs' to die with the fatal error "Not a glob reference at". This even broke the 5.10 debugger.

    I think this optimization was included too cavalierly and it should become optional (an environment variable makes for an easy control mechanism) for 5.10.1.

    - tye        

Re: namespace::clean and "Unknown Error"
by dk (Chaplain) on Feb 17, 2009 at 14:33 UTC
    Just ask phaylon directly. namespace::clean is both cool and useful, but that heavy magic that cuts directly into parser I think is a bit misplaced, and is showing in cases like yours. I'm planning to do some venture in this area myself, and with different perspective, so if you're interested I can ping you later if I find something more practical.
Re: namespace::clean and "Unknown Error"
by Anonymous Monk on Feb 16, 2009 at 19:01 UTC
    namespace::clean is useless. If you don't want imports, just be explicit
    use Foo(); no Foo; # unimport

      Which is a pretty clear indication that you have no idea what it does. Being able to import all the handy utility methods I need from whatever libraries I like without having all those imported functions appear as methods on the object is extremely useful.


      www.jasonkohles.com
      We're not surrounded, we're in a target-rich environment!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://744169]
Approved by ikegami
Front-paged by tye
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-03-29 13:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found