fholm / IronJS

IronJS - A JavaScript implementation for .NET
http://ironjs.wordpress.com
Apache License 2.0
680 stars 79 forks source link

NullReferenceException when executing 'process.js' of UglifyJS #51

Closed asbjornu closed 13 years ago

asbjornu commented 13 years ago

When executing the file process.js, I get an exception:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
    at lambda_method(Closure , FunctionObject , CommonObject )
    --- End of inner exception stack trace ---
    at IronJS.Hosting.FSharp.run(Delegate compiled, T t) in D:\AUL\Dev\Misc\IronJS\Src\IronJS\Hosting.fs:line 152
    at IronJS.Hosting.CSharp.Context.Execute[a](String source) in D:\AUL\Dev\Misc\IronJS\Src\IronJS\Hosting.fs:line 244
    at Uglify.Requirer.RequireAndAddToCache(String file) in D:\AUL\Dev\Misc\Uglify.NET\src\app\Uglify\Requirer.cs:line 92
    at Uglify.Requirer.RequireInternal(String file) in D:\AUL\Dev\Misc\Uglify.NET\src\app\Uglify\Requirer.cs:line 106
    at lambda_method(Closure , FunctionObject , CommonObject , String )
    at lambda_method(Closure , FunctionObject , CommonObject )
    --- End of inner exception stack trace ---
    at IronJS.Hosting.FSharp.run(Delegate compiled, T t) in D:\AUL\Dev\Misc\IronJS\Src\IronJS\Hosting.fs:line 152
    at IronJS.Hosting.CSharp.Context.Execute[a](String source) in D:\AUL\Dev\Misc\IronJS\Src\IronJS\Hosting.fs:line 244
    at Uglify.Uglifier.Uglify(String code) in D:\AUL\Dev\Misc\Uglify.NET\src\app\Uglify\Uglifier.cs:line 40
    at Uglify.Terminal.Terminal.Main() in D:\AUL\Dev\Misc\Uglify.NET\src\tests\Terminal\Terminal.cs:line 12

Since IronJS only fails with a NullReferenceException, I'm having difficulties figuring out what the problem with this file might be. Care to take a look at it?

asbjornu commented 13 years ago

I'm pretty confident there's something within process.js that isn't fully ES3 compatible (and that should be fixed in UglifyJS), but I'm unable to locate the error because NullReferenceException is thrown. Had a more meaningful exception been thrown in IronJS, I might have been able to resolve this issue myself.

otac0n commented 13 years ago

Are you still having this issue?

asbjornu commented 13 years ago

No, after your pull request, everything is working much better thank you. :) However, it would be nice if IronJS never threw NullReferenceException, since they are virtually impossible to debug. Doing some "if null" checks and throwing more meaningful exceptions would be great.

otac0n commented 13 years ago

Yeah, I'm working on the error messages. I'll close this issue, since we already have one for the error messages.

asbjornu commented 13 years ago

If throwing more meaningful exceptions also involve avoiding NullReferenceException, then great. :-)