@@ -9,6 +9,7 @@ import { walk } from 'estree-walker';
9
9
import { extract_identifiers } from 'periscopic' ;
10
10
import is_reference from 'is-reference' ;
11
11
import get_object from '../utils/get_object' ;
12
+ import compiler_errors from '../compiler_errors' ;
12
13
13
14
const allowed_parents = new Set ( [ 'EachBlock' , 'CatchBlock' , 'ThenBlock' , 'InlineComponent' , 'SlotTemplate' ] ) ;
14
15
@@ -26,7 +27,7 @@ export default class ConstTag extends Node {
26
27
super ( component , parent , scope , info ) ;
27
28
28
29
if ( ! allowed_parents . has ( parent . type ) ) {
29
- component . error ( info , { code : 'invalid-const-placement' , message : '{@const} must be the immediate child of {#each}, {:then}, {:catch}, <svelte:fragment> and <Component>' } ) ;
30
+ component . error ( info , compiler_errors . invalid_const_placement ) ;
30
31
}
31
32
this . node = info ;
32
33
this . scope = scope ;
@@ -37,7 +38,7 @@ export default class ConstTag extends Node {
37
38
assignees . add ( name ) ;
38
39
const owner = this . scope . get_owner ( name ) ;
39
40
if ( owner === parent ) {
40
- component . error ( info , { code : 'invalid-const-declaration' , message : `' ${ name } ' has already been declared` } ) ;
41
+ component . error ( info , compiler_errors . invalid_const_declaration ( name ) ) ;
41
42
}
42
43
} ) ;
43
44
@@ -51,14 +52,14 @@ export default class ConstTag extends Node {
51
52
}
52
53
} ) ;
53
54
}
54
-
55
+
55
56
parse_expression ( ) {
56
57
unpack_destructuring ( this . contexts , this . node . expression . left ) ;
57
58
this . expression = new Expression ( this . component , this , this . scope , this . node . expression . right ) ;
58
59
this . contexts . forEach ( context => {
59
60
const owner = this . scope . get_owner ( context . key . name ) ;
60
61
if ( owner && owner . type === 'ConstTag' && owner . parent === this . parent ) {
61
- this . component . error ( this . node , { code : 'invalid-const-declaration' , message : `' ${ context . key . name } ' has already been declared` } ) ;
62
+ this . component . error ( this . node , compiler_errors . invalid_const_declaration ( context . key . name ) ) ;
62
63
}
63
64
this . scope . add ( context . key . name , this . expression . dependencies , this ) ;
64
65
} ) ;
0 commit comments