Bug 139418 - A "cached" null setter should throw a TypeException when called in strict mode and doesn't
Summary: A "cached" null setter should throw a TypeException when called in strict mod...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Michael Saboff
URL:
Keywords: InRadar
Depends on: 139229
Blocks:
  Show dependency treegraph
 
Reported: 2014-12-08 15:29 PST by Michael Saboff
Modified: 2015-01-20 17:29 PST (History)
0 users

See Also:


Attachments
Test to demonstrate issue (2.49 KB, application/octet-stream)
2014-12-08 15:34 PST, Michael Saboff
no flags Details
Patch (22.50 KB, patch)
2015-01-19 18:22 PST, Michael Saboff
fpizlo: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Saboff 2014-12-08 15:29:25 PST
The put by id caching only has logic to return undefined when a setter is null.  The ECMAScript spec requires that a null setter throws a TypeException.  The (soon to be) attached test demonstrates the problem.
Comment 1 Michael Saboff 2014-12-08 15:34:27 PST
Created attachment 242855 [details]
Test to demonstrate issue
Comment 2 Michael Saboff 2014-12-08 16:34:56 PST
<rdar://problem/19183271>
Comment 3 Michael Saboff 2015-01-19 18:22:44 PST
Created attachment 244949 [details]
Patch
Comment 4 Filip Pizlo 2015-01-19 21:05:44 PST
Comment on attachment 244949 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=244949&action=review

r+ modulo style

> Source/JavaScriptCore/runtime/NullSetterFunction.h:27
> +#ifndef NullSetterFunction_h
> +#define  NullSetterFunction_h

Remove the extra space.
Comment 5 Michael Saboff 2015-01-19 21:27:59 PST
Committed r178696: <http://trac.webkit.org/changeset/178696>
Comment 6 Geoffrey Garen 2015-01-20 12:10:47 PST
Comment on attachment 244949 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=244949&action=review

> Source/JavaScriptCore/runtime/NullSetterFunction.cpp:96
> +ConstructType NullSetterFunction::getConstructData(JSCell*, ConstructData& constructData)
> +{
> +    constructData.native.function = constructReturnUndefined;
> +    return ConstructTypeHost;
> +}

This looks wrong. A setter can't be called as a constructor, can it? I don't think your test covers this case, either. You should probably remove the constructor path.
Comment 7 Michael Saboff 2015-01-20 17:29:59 PST
(In reply to comment #6)
> Comment on attachment 244949 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=244949&action=review
> 
> > Source/JavaScriptCore/runtime/NullSetterFunction.cpp:96
> > +ConstructType NullSetterFunction::getConstructData(JSCell*, ConstructData& constructData)
> > +{
> > +    constructData.native.function = constructReturnUndefined;
> > +    return ConstructTypeHost;
> > +}
> 
> This looks wrong. A setter can't be called as a constructor, can it? I don't
> think your test covers this case, either. You should probably remove the
> constructor path.

Filed <https://bugs.webkit.org/show_bug.cgi?id=140708> - "Eliminate construct methods from NullGetterFunction and NullSetterFunction classes" to track removing the constructor path.