Skip to content

Commit

Permalink
Fix #282
Browse files Browse the repository at this point in the history
  • Loading branch information
nilproject committed Jan 25, 2023
1 parent 4fef2a9 commit 8facfe7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions NiL.JS/BaseLibrary/JSON.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private class StackFrame
[ArgumentsCount(2)]
public static JSValue parse(Arguments args)
{
var length = Tools.JSObjectToInt32(args._iValue);
var length = args._iValue;
var code = args[0].ToString();
Function reviewer = length > 1 ? args[1]._oValue as Function : null;
return parse(code, reviewer);
Expand Down Expand Up @@ -474,7 +474,7 @@ private static string stringifyImpl(string key, JSValue obj, Function replacer,
processed.Add(obj);

if (obj.Value == null)
return null;
return "null";

if (obj._valueType == JSValueType.Function)
return null;
Expand Down
3 changes: 3 additions & 0 deletions NiL.JS/Core/JSValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,9 @@ private object debugValue()
return Value;
}

if (Value is null)
return "null";

return (_oValue as JSValue ?? this)._valueType;
}

Expand Down
2 changes: 2 additions & 0 deletions Tests/Fuzz/Bug_282.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
if (JSON.stringify({ a: null }) !== '{"a":null}')
console.error("JSON.stringify ignores null");

0 comments on commit 8facfe7

Please sign in to comment.