fix: prevent invalid BigInt calls from blowing up at compile time (#15900)

pull/15902/head
Rich Harris 4 months ago committed by GitHub
parent df03af2e9d
commit eebb940b31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: prevent invalid BigInt calls from blowing up at compile time

@ -23,7 +23,7 @@ export const STRING = Symbol('string');
/** @type {Record<string, [type: NUMBER | STRING | UNKNOWN, fn?: Function]>} */
const globals = {
BigInt: [NUMBER, BigInt],
BigInt: [NUMBER],
'Math.min': [NUMBER, Math.min],
'Math.max': [NUMBER, Math.max],
'Math.random': [NUMBER],

@ -0,0 +1,7 @@
import { test } from '../../test';
export default test({
// check that this is a runtime error, not a compile time error
// caused by over-eager partial-evaluation
error: 'Cannot convert invalid to a BigInt'
});

@ -0,0 +1,5 @@
<script>
var invalid = BigInt('invalid');
</script>
<h1>{invalid}</h1>
Loading…
Cancel
Save