Explorar o código

Fixes #804 Json parsing errors mention JSON.parse in errors

Manoj Patel %!s(int64=9) %!d(string=hai) anos
pai
achega
2f634ae0c1

+ 11 - 0
lib/Parser/rterrors.h

@@ -342,3 +342,14 @@ RT_ERROR_MSG(JSERR_ResolveExportFailed, 5647, "Resolve export %s failed due to c
 
 RT_ERROR_MSG(JSERR_ObjectCoercible, 5648, "", "Cannot convert null or undefined to object", kjstTypeError, 0)
 RT_ERROR_MSG(JSERR_SIMDConversion, 5649, "%s: cannot be converted to a number", "Cannot be converted to a number", kjstTypeError, 0)
+
+
+// JSON.parse errors. When this happens we want to make it explicitly clear the issue is in JSON.parse and not in the code
+RT_ERROR_MSG(JSERR_JsonSyntax, 5650, "JSON.parse Error: Unexpected input at position:%s", "JSON.parse syntax error", kjstTypeError, 0)
+RT_ERROR_MSG(JSERR_JsonNoColon, 5651,"JSON.parse Error: Expected ':' at position:%s", "JSON.parse syntax error", kjstTypeError, 0)
+RT_ERROR_MSG(JSERR_JsonNoRbrack, 5652, "JSON.parse Error: Expected ']' at position:%s", "JSON.parse syntax error", kjstTypeError, 0)
+RT_ERROR_MSG(JSERR_JsonNoRcurly, 5653, "JSON.parse Error: Expected '}' at position:%s", "JSON.parse syntax error", kjstTypeError, 0)
+RT_ERROR_MSG(JSERR_JsonBadNumber, 5654, "JSON.parse Error: Invalid number at position:%s", "JSON.parse syntax error", kjstTypeError, 0)
+RT_ERROR_MSG(JSERR_JsonIllegalChar, 5655, "JSON.parse Error: Invalid character at position:%s", "JSON.parse syntax error", kjstTypeError, 0)
+RT_ERROR_MSG(JSERR_JsonBadHexDigit, 5656, "JSON.parse Error: Expected hexadecimal digit at position:%s", "JSON.parse syntax error", kjstTypeError, 0)
+RT_ERROR_MSG(JSERR_JsonNoStrEnd, 5657, "JSON.parse Error: Unterminated string constant at position:%s", "JSON.parse syntax error", kjstTypeError, 0)

+ 9 - 9
lib/Runtime/Library/JSONParser.cpp

@@ -35,7 +35,7 @@ namespace JSON
         Js::Var ret = ParseObject();
         if (m_token.tk != tkEOF)
         {
-            Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRsyntax);
+            m_scanner.ThrowSyntaxError(JSERR_JsonSyntax);
         }
         return ret;
     }
@@ -232,7 +232,7 @@ namespace JSON
             }
             else
             {
-                Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRbadNumber);
+                m_scanner.ThrowSyntaxError(JSERR_JsonBadNumber);
             }
 
         case tkLBrack:
@@ -260,11 +260,11 @@ namespace JSON
                     Scan();
                     if(tkRBrack == m_token.tk)
                     {
-                        Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRillegalChar);
+                        m_scanner.ThrowSyntaxError(JSERR_JsonIllegalChar);
                     }
                 }
                 //check and consume the ending ']'
-                CheckCurrentToken(tkRBrack, ERRnoRbrack);
+                CheckCurrentToken(tkRBrack, JSERR_JsonNoRbrack);
                 return arrayObj;
 
             }
@@ -311,7 +311,7 @@ namespace JSON
                     //pick "name"
                     if(tkStrCon != m_token.tk)
                     {
-                        Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRsyntax);
+                        m_scanner.ThrowSyntaxError(JSERR_JsonIllegalChar);
                     }
 
                     // currentStrLength = length w/o null-termination
@@ -332,7 +332,7 @@ namespace JSON
                             //check and consume ":"
                             if(Scan() != tkColon )
                             {
-                                Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRnoColon);
+                                m_scanner.ThrowSyntaxError(JSERR_JsonNoColon);
                             }
                             Scan();
 
@@ -365,7 +365,7 @@ namespace JSON
                     //check and consume ":"
                     if(Scan() != tkColon )
                     {
-                        Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRnoColon);
+                        m_scanner.ThrowSyntaxError(JSERR_JsonNoColon);
                     }
                     Scan();
                     Js::Var value = ParseObject();
@@ -404,12 +404,12 @@ namespace JSON
                 }
 
                 // check  and consume the ending '}"
-                CheckCurrentToken(tkRCurly, ERRnoRcurly);
+                CheckCurrentToken(tkRCurly, JSERR_JsonNoRcurly);
                 return object;
             }
 
         default:
-            Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRsyntax);
+            m_scanner.ThrowSyntaxError(JSERR_JsonSyntax);
         }
     }
 } // namespace JSON

+ 1 - 1
lib/Runtime/Library/JSONParser.h

@@ -70,7 +70,7 @@ namespace JSON
         void CheckCurrentToken(int tk, int wErr)
         {
             if (m_token.tk != tk)
-                Js::JavascriptError::ThrowSyntaxError(scriptContext, wErr);
+                m_scanner.ThrowSyntaxError(wErr);
             Scan();
         }
 

+ 17 - 17
lib/Runtime/Library/JSONScanner.cpp

@@ -82,7 +82,7 @@ namespace JSON
                     const char16* saveCurrentChar = currentChar;
                     if(!IsJSONNumber())
                     {
-                        Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRbadNumber);
+                       ThrowSyntaxError(JSERR_JsonBadNumber);
                     }
                     currentChar = saveCurrentChar;
                     double val;
@@ -90,7 +90,7 @@ namespace JSON
                     val = Js::NumberUtilities::StrToDbl(currentChar, &end, scriptContext);
                     if(currentChar == end)
                     {
-                        Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRbadNumber);
+                       ThrowSyntaxError(JSERR_JsonBadNumber);
                     }
                     AssertMsg(!Js::JavascriptNumber::IsNan(val), "Bad result from string to double conversion");
                     pToken->tk = tkFltCon;
@@ -121,7 +121,7 @@ namespace JSON
                     currentChar += 3;
                     return (pToken->tk = tkNULL);
                 }
-                Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRillegalChar);
+               ThrowSyntaxError(JSERR_JsonIllegalChar);
 
             case 't':
                 //check for 'true'
@@ -130,7 +130,7 @@ namespace JSON
                     currentChar += 3;
                     return (pToken->tk = tkTRUE);
                 }
-                Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRillegalChar);
+               ThrowSyntaxError(JSERR_JsonIllegalChar);
 
             case 'f':
                 //check for 'false'
@@ -139,7 +139,7 @@ namespace JSON
                     currentChar += 4;
                     return (pToken->tk = tkFALSE);
                 }
-                Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRillegalChar);
+               ThrowSyntaxError(JSERR_JsonIllegalChar);
 
             case '{':
                 return (pToken->tk = tkLCurly);
@@ -148,7 +148,7 @@ namespace JSON
                 return (pToken->tk = tkRCurly);
 
             default:
-                Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRillegalChar);
+               ThrowSyntaxError(JSERR_JsonIllegalChar);
             }
 
         }
@@ -245,12 +245,12 @@ namespace JSON
             else if (ch <= 0x1F)
             {
                 //JSON doesn't accept \u0000 - \u001f range, LS(\u2028) and PS(\u2029) are ok
-                Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRillegalChar);
+               ThrowSyntaxError(JSERR_JsonIllegalChar);
             }
             else if ( 0 == ch )
             {
                 currentChar--;
-                Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRnoStrEnd);
+               ThrowSyntaxError(JSERR_JsonNoStrEnd);
             }
             else if ('\\' == ch)
             {
@@ -258,7 +258,7 @@ namespace JSON
                 // unlikely V5.8 regular chars are not escaped, i.e '\g'' in a string is illegal not 'g'
                 if (currentChar >= inputText + inputLen )
                 {
-                    Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRnoStrEnd);
+                   ThrowSyntaxError(JSERR_JsonNoStrEnd);
                 }
 
                 ch = ReadNextChar();
@@ -266,7 +266,7 @@ namespace JSON
                 {
                 case 0:
                     currentChar--;
-                    Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRnoStrEnd);
+                   ThrowSyntaxError(JSERR_JsonNoStrEnd);
 
                 case '"':
                 case '/':
@@ -301,30 +301,30 @@ namespace JSON
                         if (currentChar + 3 >= inputText + inputLen)
                         {
                             //no room left for 4 hex chars
-                            Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRnoStrEnd);
+                           ThrowSyntaxError(JSERR_JsonNoStrEnd);
 
                         }
                         if (!Js::NumberUtilities::FHexDigit((WCHAR)ReadNextChar(), &tempHex))
                         {
-                            Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRbadHexDigit);
+                           ThrowSyntaxError(JSERR_JsonBadHexDigit);
                         }
                         chcode = tempHex * 0x1000;
 
                         if (!Js::NumberUtilities::FHexDigit((WCHAR)ReadNextChar(), &tempHex))
                         {
-                            Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRbadHexDigit);
+                           ThrowSyntaxError(JSERR_JsonBadHexDigit);
                         }
                         chcode += tempHex * 0x0100;
 
                         if (!Js::NumberUtilities::FHexDigit((WCHAR)ReadNextChar(), &tempHex))
                         {
-                            Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRbadHexDigit);
+                           ThrowSyntaxError(JSERR_JsonBadHexDigit);
                         }
                         chcode += tempHex * 0x0010;
 
                         if (!Js::NumberUtilities::FHexDigit((WCHAR)ReadNextChar(), &tempHex))
                         {
-                            Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRbadHexDigit);
+                           ThrowSyntaxError(JSERR_JsonBadHexDigit);
                         }
                         chcode += tempHex;
                         AssertMsg(chcode == (chcode & 0xFFFF), "Bad unicode code");
@@ -334,7 +334,7 @@ namespace JSON
 
                 default:
                     // Any other '\o' is an error in JSON
-                    Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRillegalChar);
+                   ThrowSyntaxError(JSERR_JsonIllegalChar);
                 }
 
                 // flush
@@ -367,7 +367,7 @@ namespace JSON
         if (!endFound)
         {
             // no ending '"' found
-            Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRnoStrEnd);
+           ThrowSyntaxError(JSERR_JsonNoStrEnd);
         }
 
         if (isStringDirectInputTextMapped == false)

+ 9 - 2
lib/Runtime/Library/JSONScanner.h

@@ -20,9 +20,16 @@ namespace JSON
             ::Js::ScriptContext* sc, const char16* current, ArenaAllocator* allocator);
 
         void Finalizer();
-        char16* GetCurrentString(){return currentString;}
-        uint GetCurrentStringLen(){return currentIndex;}
+        char16* GetCurrentString() { return currentString; } 
+        uint GetCurrentStringLen() { return currentIndex; }
+        uint GetScanPosition() { return uint(currentChar - inputText); }
 
+        void __declspec(noreturn) ThrowSyntaxError(int wErr)
+        {
+            char16 scanPos[16];
+            ::_itow_s(GetScanPosition(), scanPos, _countof(scanPos) / sizeof(char16), 10);
+            Js::JavascriptError::ThrowSyntaxError(scriptContext, wErr, scanPos);
+        }
 
     private:
 

+ 37 - 37
test/JSON/jx2.baseline

@@ -194,7 +194,7 @@ null
 
 ------ JSON test stringify: undefined  ------
 undefined
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:1
 
 ------ JSON test stringify: Date(2008, 10, 10)  ------
 "2008-11-10T08:00:00.000Z"
@@ -328,7 +328,7 @@ null
 
 ------ JSON test stringify: undefined  ------
 undefined
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:1
 
 ------ JSON test stringify: Date(2008, 10, 10)  ------
 "2008-11-10T08:00:00.000Z"
@@ -462,7 +462,7 @@ null
 
 ------ JSON test stringify: undefined  ------
 undefined
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:1
 
 ------ JSON test stringify: Date(2008, 10, 10)  ------
 "2008-11-10T08:00:00.000Z"
@@ -655,7 +655,7 @@ null
 
 ------ JSON test stringify: undefined  ------
 undefined
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:1
 
 ------ JSON test stringify: Date(2008, 10, 10)  ------
 "2008-11-10T08:00:00.000Z"
@@ -848,7 +848,7 @@ null
 
 ------ JSON test stringify: undefined  ------
 undefined
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:1
 
 ------ JSON test stringify: Date(2008, 10, 10)  ------
 "2008-11-10T08:00:00.000Z"
@@ -885,7 +885,7 @@ true
 .........."nullMember": null,
 .........."stringmember": "this string ends the obj. You should not see functionMember and undefinedMember"
 }
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:3
 
 ------ JSON test stringify: Object with nested objects and array  ------
 {
@@ -915,14 +915,14 @@ true
 ..........},
 .........."stringmember": "this string ends the obj. You should not see functionMember and undefinedMember"
 }
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:3
 
 ------ JSON test stringify: Simple array  ------
 [
 .........."document.location",
 .........."foolish"
 ]
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:3
 
 ------ JSON test stringify: Complex array  ------
 [
@@ -951,7 +951,7 @@ true
 ..........],
 .........."[0]-document.location, [1]-string, [2]-number, [3]-date, [4]-empty obj, [5]-missing, [6]-obj, [7]-null, [8]-undef, [9]-function, [10]-nestedArray, [11]-this"
 ]
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:3
 
 
 
@@ -1029,7 +1029,7 @@ null
 
 ------ JSON test stringify: undefined  ------
 undefined
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:1
 
 ------ JSON test stringify: Date(2008, 10, 10)  ------
 "2008-11-10T08:00:00.000Z"
@@ -1163,7 +1163,7 @@ null
 
 ------ JSON test stringify: undefined  ------
 undefined
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:1
 
 ------ JSON test stringify: Date(2008, 10, 10)  ------
 "2008-11-10T08:00:00.000Z"
@@ -1319,7 +1319,7 @@ null
 
 ------ JSON test stringify: undefined  ------
 undefined
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:1
 
 ------ JSON test stringify: Date(2008, 10, 10)  ------
 "2008-11-10T08:00:00.000Z"
@@ -1475,7 +1475,7 @@ null
 
 ------ JSON test stringify: undefined  ------
 undefined
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:1
 
 ------ JSON test stringify: Date(2008, 10, 10)  ------
 "2008-11-10T08:00:00.000Z"
@@ -1524,7 +1524,7 @@ true
 .........."document.location",
 .........."foolish"
 ]
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:3
 
 ------ JSON test stringify: Complex array  ------
 [
@@ -1547,7 +1547,7 @@ true
 ..........],
 .........."[0]-document.location, [1]-string, [2]-number, [3]-date, [4]-empty obj, [5]-missing, [6]-obj, [7]-null, [8]-undef, [9]-function, [10]-nestedArray, [11]-this"
 ]
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:3
 
 
 
@@ -1625,7 +1625,7 @@ null
 
 ------ JSON test stringify: undefined  ------
 undefined
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:1
 
 ------ JSON test stringify: Date(2008, 10, 10)  ------
 "2008-11-10T08:00:00.000Z"
@@ -1759,7 +1759,7 @@ null
 
 ------ JSON test stringify: undefined  ------
 undefined
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:1
 
 ------ JSON test stringify: Date(2008, 10, 10)  ------
 "2008-11-10T08:00:00.000Z"
@@ -1925,7 +1925,7 @@ null
 
 ------ JSON test stringify: undefined  ------
 undefined
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:1
 
 ------ JSON test stringify: Date(2008, 10, 10)  ------
 "2008-11-10T08:00:00.000Z"
@@ -2091,7 +2091,7 @@ null
 
 ------ JSON test stringify: undefined  ------
 undefined
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:1
 
 ------ JSON test stringify: Date(2008, 10, 10)  ------
 "2008-11-10T08:00:00.000Z"
@@ -2138,14 +2138,14 @@ true
 ....................}
 ..........}
 }
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:3
 
 ------ JSON test stringify: Simple array  ------
 [
 .........."document.location",
 .........."foolish"
 ]
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:3
 
 ------ JSON test stringify: Complex array  ------
 [
@@ -2170,7 +2170,7 @@ true
 ..........],
 .........."[0]-document.location, [1]-string, [2]-number, [3]-date, [4]-empty obj, [5]-missing, [6]-obj, [7]-null, [8]-undef, [9]-function, [10]-nestedArray, [11]-this"
 ]
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:3
 
 
 
@@ -2248,7 +2248,7 @@ null
 
 ------ JSON test stringify: undefined  ------
 undefined
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:1
 
 ------ JSON test stringify: Date(2008, 10, 10)  ------
 "2008-11-10T08:00:00.000Z"
@@ -2382,7 +2382,7 @@ null
 
 ------ JSON test stringify: undefined  ------
 undefined
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:1
 
 ------ JSON test stringify: Date(2008, 10, 10)  ------
 "2008-11-10T08:00:00.000Z"
@@ -2548,7 +2548,7 @@ null
 
 ------ JSON test stringify: undefined  ------
 undefined
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:1
 
 ------ JSON test stringify: Date(2008, 10, 10)  ------
 "2008-11-10T08:00:00.000Z"
@@ -2714,7 +2714,7 @@ null
 
 ------ JSON test stringify: undefined  ------
 undefined
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:1
 
 ------ JSON test stringify: Date(2008, 10, 10)  ------
 "2008-11-10T08:00:00.000Z"
@@ -2761,14 +2761,14 @@ true
 ....................}
 ..........}
 }
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:3
 
 ------ JSON test stringify: Simple array  ------
 [
 .........."document.location",
 .........."foolish"
 ]
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:3
 
 ------ JSON test stringify: Complex array  ------
 [
@@ -2793,7 +2793,7 @@ true
 ..........],
 .........."[0]-document.location, [1]-string, [2]-number, [3]-date, [4]-empty obj, [5]-missing, [6]-obj, [7]-null, [8]-undef, [9]-function, [10]-nestedArray, [11]-this"
 ]
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:3
 
 
 
@@ -2871,7 +2871,7 @@ null
 
 ------ JSON test stringify: undefined  ------
 undefined
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:1
 
 ------ JSON test stringify: Date(2008, 10, 10)  ------
 "2008-11-10T08:00:00.000Z"
@@ -3005,7 +3005,7 @@ null
 
 ------ JSON test stringify: undefined  ------
 undefined
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:1
 
 ------ JSON test stringify: Date(2008, 10, 10)  ------
 "2008-11-10T08:00:00.000Z"
@@ -3202,7 +3202,7 @@ null
 
 ------ JSON test stringify: undefined  ------
 undefined
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:1
 
 ------ JSON test stringify: Date(2008, 10, 10)  ------
 "2008-11-10T08:00:00.000Z"
@@ -3399,7 +3399,7 @@ null
 
 ------ JSON test stringify: undefined  ------
 undefined
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:1
 
 ------ JSON test stringify: Date(2008, 10, 10)  ------
 "2008-11-10T08:00:00.000Z"
@@ -3436,7 +3436,7 @@ true
 .........."nullMember": null,
 .........."stringmember": "this string ends the obj. You should not see functionMember and undefinedMember"
 }
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:3
 
 ------ JSON test stringify: Object with nested objects and array  ------
 {
@@ -3470,14 +3470,14 @@ true
 ..........},
 .........."stringmember": "this string ends the obj. You should not see functionMember and undefinedMember"
 }
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:3
 
 ------ JSON test stringify: Simple array  ------
 [
 .........."document.location",
 .........."foolish"
 ]
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:3
 
 ------ JSON test stringify: Complex array  ------
 [
@@ -3506,4 +3506,4 @@ true
 ..........],
 .........."[0]-document.location, [1]-string, [2]-number, [3]-date, [4]-empty obj, [5]-missing, [6]-obj, [7]-null, [8]-undef, [9]-function, [10]-nestedArray, [11]-this"
 ]
-!!Exception: SyntaxError: Invalid character
+!!Exception: SyntaxError: JSON.parse Error: Invalid character at position:3

+ 6 - 0
test/JSON/rlexe.xml

@@ -89,4 +89,10 @@
       <baseline>jsonParseWalkTest.baseline</baseline>
     </default>
   </test>
+  <test>
+    <default>
+      <files>syntaxError.js</files>
+      <baseline>syntaxError.baseline</baseline>
+    </default>
+  </test>
 </regress-exe>

+ 7 - 0
test/JSON/syntaxError.baseline

@@ -0,0 +1,7 @@
+SyntaxError: JSON.parse Error: Unexpected input at position:0
+SyntaxError: JSON.parse Error: Invalid number at position:2
+SyntaxError: JSON.parse Error: Unterminated string constant at position:9
+SyntaxError: JSON.parse Error: Expected ':' at position:9
+SyntaxError: JSON.parse Error: Expected '}' at position:9
+SyntaxError: JSON.parse Error: Expected ']' at position:3
+SyntaxError: JSON.parse Error: Invalid character at position:5

+ 12 - 0
test/JSON/syntaxError.js

@@ -0,0 +1,12 @@
+//-------------------------------------------------------------------------------------------------------
+// Copyright (C) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
+//-------------------------------------------------------------------------------------------------------
+
+try { JSON.parse(''); } catch(e) { WScript.Echo(e); }
+try { JSON.parse('--'); } catch(e) { WScript.Echo(e); }
+try { JSON.parse('{"asdf  }'); } catch(e) { WScript.Echo(e); }
+try { JSON.parse('{"asdf" }'); } catch(e) { WScript.Echo(e); }
+try { JSON.parse('{"asdf":1'); } catch(e) { WScript.Echo(e); }
+try { JSON.parse("[23"); } catch(e) { WScript.Echo(e); }
+try { JSON.parse("[23,]"); } catch(e) { WScript.Echo(e); }