Skip to content

Commit bece149

Browse files
committed
fixes
1 parent 9e3c4d5 commit bece149

File tree

7 files changed

+16
-7
lines changed

7 files changed

+16
-7
lines changed

.changeset/itchy-beans-melt.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+
chore: fix compiler errors test suite

packages/svelte/src/compiler/phases/1-parse/state/element.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ export default function tag(parser) {
205205
if (attribute.type === 'Attribute' || attribute.type === 'BindDirective') {
206206
if (unique_names.includes(attribute.name)) {
207207
error(attribute.start, 'duplicate-attribute');
208-
} else {
208+
// <svelte:element bind:this this=..> is allowed
209+
} else if (attribute.name !== 'this') {
209210
unique_names.push(attribute.name);
210211
}
211212
}

packages/svelte/tests/compiler-errors/samples/export-derived-state/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ export default test({
44
error: {
55
code: 'invalid-derived-export',
66
message: 'Cannot export derived state',
7-
position: process.platform === 'win32' ? [26, 68] : [24, 66]
7+
position: [24, 66]
88
}
99
});

packages/svelte/tests/compiler-errors/samples/export-state/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ export default test({
44
error: {
55
code: 'invalid-state-export',
66
message: 'Cannot export state if it is reassigned',
7-
position: process.platform === 'win32' ? [50, 90] : [46, 86]
7+
position: [46, 86]
88
}
99
});

packages/svelte/tests/compiler-errors/samples/runes-export-named-state/_config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { test } from '../../test';
22

33
export default test({
44
error: {
5-
code: '',
6-
message: 'Cannot export value created with $state'
5+
code: 'invalid-state-export',
6+
message: 'Cannot export state if it is reassigned',
7+
position: [28, 53]
78
}
89
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
export const x = $state(0);
2+
export let y = $state(0);
3+
y = 1;

packages/svelte/tests/compiler-errors/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ const { test, run } = suite<CompilerErrorTest>((config, cwd) => {
5454

5555
caught_error = true;
5656

57-
expect(error.code).toMatch(config.error.code);
58-
expect(error.message).toMatch(config.error.message);
57+
expect(error.code).toEqual(config.error.code);
58+
expect(error.message).toEqual(config.error.message);
5959

6060
if (config.error.position) {
6161
expect(error.position).toEqual(config.error.position);

0 commit comments

Comments
 (0)