8000 fix: prevent invalid BigInt calls from blowing up at compile time · sveltejs/svelte@b25ab18 · GitHub
[go: up one dir, main page]

Skip to content

Commit b25ab18

Browse files
committed
fix: prevent invalid BigInt calls from blowing up at compile time
1 parent df03af2 commit b25ab18

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

.changeset/little-worms-wonder.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: prevent invalid BigInt calls from blowing up at compile time

packages/svelte/src/compiler/phases/scope.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const STRING = Symbol('string');
2323

2424
/** @type {Record<string, [type: NUMBER | STRING | UNKNOWN, fn?: Function]>} */
2525
const globals = {
26-
BigInt: [NUMBER, BigInt],
26+
BigInt: [NUMBER],
2727
'Math.min': [NUMBER, Math.min],
2828
'Math.max': [NUMBER, Math.max],
2929
'Math.random': [NUMBER],
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
// check that this is a runtime error, not a compile time error
5+
// caused by over-eager partial-evaluation
6+
error: 'Cannot convert invalid to a BigInt'
7+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script>
2+
var invalid = BigInt('invalid');
3+
</script>
4+
5+
<h1>{invalid}</h1>

0 commit comments

Comments
 (0)
0