paulbartrum / jurassic

A .NET library to parse and execute JavaScript code.
MIT License
873 stars 122 forks source link

Can't pass "null" as value in "SetGlobalValue"? #100

Closed highfield closed 7 years ago

highfield commented 7 years ago

I think there's something strange at the top of the "SetGlobalValue" method. https://github.com/paulbartrum/jurassic/blob/master/Jurassic/Core/ScriptEngine.cs#L944 I wish to pass either null (CLR) or Null (Jurassic) for a global variable, but it seems that both are throwing a (different) exception. If I pass null (CLR), the method throws an ArgumentNullException. If I pass Jurassic.Null.Value, the method fails because it considers the value as a CLR-object (not supported). I believe that the contract exception for the CLR-null is wrong: by removing it, it seems working fine. Thanks in advance.

paulbartrum commented 7 years ago

Yeah, you're right, it's wrong. I've checked in a fix (950b1d2435bd18e7c648afadb899c597d9a0d490).

Sorry for the delay.