File tree 4 files changed +22
-0
lines changed
test/validator/samples/catch-declares-error-variable
4 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,13 @@ export function create_scopes(expression: Node) {
40
40
map . set ( node , scope ) ;
41
41
} else if ( / ( C l a s s | V a r i a b l e ) D e c l a r a t i o n / . test ( node . type ) ) {
42
42
scope . add_declaration ( node ) ;
43
+ } else if ( node . type === 'CatchClause' ) {
44
+ scope = new Scope ( scope , true ) ;
45
+ map . set ( node , scope ) ;
46
+
47
+ extract_names ( node . param ) . forEach ( name => {
48
+ scope . declarations . set ( name , node . param ) ;
49
+ } ) ;
43
50
} else if ( node . type === 'Identifier' && is_reference ( node as ESTreeNode , parent as ESTreeNode ) ) {
44
51
if ( ! scope . has ( node . name ) && ! globals . has ( node . name ) ) {
45
52
globals . set ( node . name , node ) ;
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ export const globals = new Set([
13
13
'document' ,
14
14
'encodeURI' ,
15
15
'encodeURIComponent' ,
16
+ 'Error' ,
16
17
'Infinity' ,
17
18
'Intl' ,
18
19
'isFinite' ,
Original file line number Diff line number Diff line change
1
+ <script >
2
+ let value = null ;
3
+ </script >
4
+
5
+ <button on:click ={event => {
6
+ try {
7
+ throw new Error (' foo' );
8
+ } catch (error ) {
9
+ value = error ;
10
+ }
11
+ }}>Click to create error</button >
12
+
13
+ {String (value )}
Original file line number Diff line number Diff line change
1
+ []
You can’t perform that action at this time.
0 commit comments