Bug 142903

Summary: Setter should have a single formal parameter, Getter no parameters
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: JavaScriptCoreAssignee: Joseph Pecoraro <joepeck>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, ggaren, joepeck, oliver, rniwa, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
[PATCH] Proposed Fix ggaren: review+, commit-queue: commit-queue-

Joseph Pecoraro
Reported 2015-03-20 01:23:48 PDT
* SUMMARY Setter should have a single formal parameter. It should not allow no parameters or multiple parameters. This has actually been the case since ES5. ES6 allows that single parameter to be a binding element (deconstructing parameter): https://people.mozilla.org/~jorendorff/es6-draft.html#sec-method-definitions > MethodDefinition[Yield] : > set PropertyName ( PropertySetParameterList ) { FunctionBody } > > PropertySetParameterList : > FormalParameter > > FormalParameter : > BindingElement * TEST js> var x = { set foo() {} }; * EXPECTED SyntaxError * ACTUAL No error. * NOTES - This would be a breaking change, but I'm not worried since other browsers throw errors: - Firefox throws an error: SyntaxError: setter functions must have one argument - Chrome throws an error: Uncaught SyntaxError: Unexpected token )
Attachments
[PATCH] Proposed Fix (140.69 KB, patch)
2015-03-20 01:41 PDT, Joseph Pecoraro
ggaren: review+
commit-queue: commit-queue-
Joseph Pecoraro
Comment 1 2015-03-20 01:26:44 PDT
Oh, at the same time, getters should have no parameters: > MethodDefinition : > get PropertyName ( ) { FunctionBody }
Joseph Pecoraro
Comment 2 2015-03-20 01:41:03 PDT
Created attachment 249096 [details] [PATCH] Proposed Fix
Radar WebKit Bug Importer
Comment 3 2015-03-20 01:42:11 PDT
Ryosuke Niwa
Comment 4 2015-03-20 10:30:14 PDT
This looks scary. There could be iOS or Mac specific content that rely on our current behavior. Perhaps we should only do it in the strict mode?
Joseph Pecoraro
Comment 5 2015-03-24 13:57:22 PDT
Still needs review!
Geoffrey Garen
Comment 6 2015-03-24 14:07:53 PDT
Comment on attachment 249096 [details] [PATCH] Proposed Fix r=me Is this what other browsers do?
Joseph Pecoraro
Comment 7 2015-03-24 14:11:58 PDT
> Is this what other browsers do? Yep! > * NOTES > - This would be a breaking change, but I'm not worried since other browsers throw errors: > - Firefox throws an error: SyntaxError: setter functions must have one argument > - Chrome throws an error: Uncaught SyntaxError: Unexpected token )
WebKit Commit Bot
Comment 8 2015-03-24 14:18:52 PDT
Comment on attachment 249096 [details] [PATCH] Proposed Fix Rejecting attachment 249096 [details] from commit-queue. Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.appspot.com', '--bot-id=webkit-cq-02', 'apply-attachment', '--no-update', '--non-interactive', 249096, '--port=mac']" exit_code: 2 cwd: /Volumes/Data/EWS/WebKit Last 500 characters of output: 1 with fuzz 3. patching file Source/JavaScriptCore/parser/Parser.cpp Hunk #1 FAILED at 1316. 1 out of 1 hunk FAILED -- saving rejects to file Source/JavaScriptCore/parser/Parser.cpp.rej patching file Source/WebInspectorUI/ChangeLog Hunk #1 succeeded at 1 with fuzz 3. patching file Source/WebInspectorUI/UserInterface/Views/GradientSlider.js Failed to run "[u'/Volumes/Data/EWS/WebKit/Tools/Scripts/svn-apply', '--force', '--reviewer', u'Geoffrey Garen']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit Full output: http://webkit-queues.appspot.com/results/4632901421367296
Joseph Pecoraro
Comment 9 2015-03-24 21:28:21 PDT
Note You need to log in before you can comment on or make changes to this bug.