Bug 163437 - test262: @isConstructor incorrectly thinks Math.cos is a constructor
Summary: test262: @isConstructor incorrectly thinks Math.cos is a constructor
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Joseph Pecoraro
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-14 01:55 PDT by Joseph Pecoraro
Modified: 2016-10-14 11:16 PDT (History)
5 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (6.92 KB, patch)
2016-10-14 02:04 PDT, Joseph Pecoraro
no flags Details | Formatted Diff | Diff
[PATCH] Proposed Fix (7.04 KB, patch)
2016-10-14 02:14 PDT, Joseph Pecoraro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2016-10-14 01:55:10 PDT
test262: @isConstructor incorrectly thinks Math.cos is a constructor
test262/test/built-ins/Array/of/return-a-new-array-object.js

@isConstructor just checks that the ConstructData is not None. However, host functions return ConstructType::Host even if their default behavior is to throw an exception that it should not be used as a constructor. We could return ConstructType::None for these default cases.
Comment 1 Joseph Pecoraro 2016-10-14 02:04:10 PDT
Created attachment 291596 [details]
[PATCH] Proposed Fix
Comment 2 Joseph Pecoraro 2016-10-14 02:14:42 PDT
Created attachment 291599 [details]
[PATCH] Proposed Fix

Some additional test cases.
Comment 3 Saam Barati 2016-10-14 07:48:26 PDT
Comment on attachment 291599 [details]
[PATCH] Proposed Fix

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

r=me

> JSTests/stress/is-constructor.js:6
> +let isConstructor = createBuiltin("(function(c) { return @isConstructor(c); })");

This is a nice test.
Comment 4 Saam Barati 2016-10-14 07:51:07 PDT
Comment on attachment 291599 [details]
[PATCH] Proposed Fix

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

r=me

>> JSTests/stress/is-constructor.js:6
>> +let isConstructor = createBuiltin("(function(c) { return @isConstructor(c); })");
> 
> This is a nice test.

This is a nice test.

> Source/JavaScriptCore/runtime/JSFunction.cpp:576
> +        if (thisObject->nativeConstructor() == callHostFunctionAsConstructor)

Do we get a new kind of error message when we try to "new" non constructor host functions?
Comment 5 Joseph Pecoraro 2016-10-14 10:53:47 PDT
Comment on attachment 291599 [details]
[PATCH] Proposed Fix

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

>> Source/JavaScriptCore/runtime/JSFunction.cpp:576
>> +        if (thisObject->nativeConstructor() == callHostFunctionAsConstructor)
> 
> Do we get a new kind of error message when we try to "new" non constructor host functions?

Nope, `new Math.cos` produces the exact same error message!
Comment 6 WebKit Commit Bot 2016-10-14 11:16:42 PDT
Comment on attachment 291599 [details]
[PATCH] Proposed Fix

Clearing flags on attachment: 291599

Committed r207347: <http://trac.webkit.org/changeset/207347>
Comment 7 WebKit Commit Bot 2016-10-14 11:16:45 PDT
All reviewed patches have been landed.  Closing bug.