Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[JSC] BigInt constructor should be constructible while it always thro…
…ws an error https://bugs.webkit.org/show_bug.cgi?id=217575 Reviewed by Darin Adler. JSTests: * stress/is-constructor.js: * stress/non-constructable-constructors.js: Added. (shouldThrow): Source/JavaScriptCore: In terms of the spec, BigInt constructor should be a constructor. So we should put constructBigIntConstructor function instead of nullptr. But it should always throw a TypeError. Error message looks a bit awkward ("TypeError: function is not a constructor..."), but this looks most intuitive to users. Note that V8 and SpiderMonkey throw similar messages ("is not a constructor"). * runtime/BigIntConstructor.cpp: (JSC::BigIntConstructor::BigIntConstructor): (JSC::JSC_DEFINE_HOST_FUNCTION): Canonical link: https://commits.webkit.org/230345@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268322 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
1 parent
d2b1564
commit 1f1ba0765ea3d3c1643dc9c348efb13a5f431e60
Showing
5 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function shouldThrow(func, errorMessage) { | ||
var errorThrown = false; | ||
var error = null; | ||
try { | ||
func(); | ||
} catch (e) { | ||
errorThrown = true; | ||
error = e; | ||
} | ||
if (!errorThrown) | ||
throw new Error('not thrown'); | ||
if (String(error) !== errorMessage) | ||
throw new Error(`bad error: ${String(error)}`); | ||
} | ||
|
||
shouldThrow(() => new Symbol(), `TypeError: function is not a constructor (evaluating 'new Symbol()')`); | ||
shouldThrow(() => new Symbol(Symbol("Hey")), `TypeError: function is not a constructor (evaluating 'new Symbol(Symbol("Hey"))')`); | ||
shouldThrow(() => new BigInt(), `TypeError: function is not a constructor (evaluating 'new BigInt()')`); | ||
shouldThrow(() => new BigInt(0), `TypeError: function is not a constructor (evaluating 'new BigInt(0)')`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters