Last Comment Bug 653847 - JSON.parse() should throw a SyntaxError, not a TypeError
: JSON.parse() should throw a SyntaxError, not a TypeError
Status: RESOLVED FIXED
fixed-in-tracemonkey
:
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: Trunk
: All All
: -- minor (vote)
: mozilla6
Assigned To: Jeff Walden [:Waldo] (remove +bmo to email)
:
: Jason Orendorff [:jorendorff]
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-04-29 15:03 PDT by Jeff Walden [:Waldo] (remove +bmo to email)
Modified: 2011-05-10 15:11 PDT (History)
0 users
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Patch and test (3.33 KB, patch)
2011-04-29 15:14 PDT, Jeff Walden [:Waldo] (remove +bmo to email)
paul.biggar: review+
Details | Diff | Splinter Review

Description Jeff Walden [:Waldo] (remove +bmo to email) 2011-04-29 15:03:39 PDT
JSON.parse doesn't care how many arguments it's called with, because it just assumes they're there (and gets undefined for any arguments that aren't, as with all spec methods).  So JSON.parse() is JSON.parse(undefined) which throws a SyntaxError, not a TypeError for not enough arguments.

This is the last spec incompatibility in JSON.parse that I'm aware of.  (Walk has some cruft to it, but I don't think any of it is spec-incompatible cruft, although it's possible I'm mistaken on the point.)
Comment 1 Jeff Walden [:Waldo] (remove +bmo to email) 2011-04-29 15:14:45 PDT
Created attachment 529216 [details] [diff] [review]
Patch and test
Comment 2 Paul Biggar 2011-05-04 07:26:12 PDT
Comment on attachment 529216 [details] [diff] [review]
Patch and test

Review of attachment 529216 [details] [diff] [review]:

+1 for the spec step comments.
Comment 3 Jeff Walden [:Waldo] (remove +bmo to email) 2011-05-04 21:25:26 PDT
http://hg.mozilla.org/tracemonkey/rev/c35425fb6956
Comment 4 Chris Leary [:cdleary] (not checking bugmail) 2011-05-10 15:11:51 PDT
cdleary-bot mozilla-central merge info:
http://hg.mozilla.org/mozilla-central/rev/c35425fb6956

Note You need to log in before you can comment on or make changes to this bug.