RESOLVED FIXED Bug 163437
test262: @isConstructor incorrectly thinks Math.cos is a constructor
https://bugs.webkit.org/show_bug.cgi?id=163437
Summary test262: @isConstructor incorrectly thinks Math.cos is a constructor
Joseph Pecoraro
Reported 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.
Attachments
[PATCH] Proposed Fix (6.92 KB, patch)
2016-10-14 02:04 PDT, Joseph Pecoraro
no flags
[PATCH] Proposed Fix (7.04 KB, patch)
2016-10-14 02:14 PDT, Joseph Pecoraro
no flags
Joseph Pecoraro
Comment 1 2016-10-14 02:04:10 PDT
Created attachment 291596 [details] [PATCH] Proposed Fix
Joseph Pecoraro
Comment 2 2016-10-14 02:14:42 PDT
Created attachment 291599 [details] [PATCH] Proposed Fix Some additional test cases.
Saam Barati
Comment 3 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.
Saam Barati
Comment 4 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?
Joseph Pecoraro
Comment 5 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!
WebKit Commit Bot
Comment 6 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>
WebKit Commit Bot
Comment 7 2016-10-14 11:16:45 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.