This repository was archived by the owner on Aug 4, 2021. It is now read-only.
File tree 2 files changed +36
-1
lines changed 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ class Scope {
65
65
// it's a `var` or function node, and this
66
66
// is a block scope, so we need to go up
67
67
this . parent . addDeclaration ( node , isBlockDeclaration , isVar ) ;
68
- } else {
68
+ } else if ( node . id ) {
69
69
extractNames ( node . id ) . forEach ( name => {
70
70
this . declarations [ name ] = true ;
71
71
} ) ;
Original file line number Diff line number Diff line change @@ -424,6 +424,41 @@ describe( 'rollup-pluginutils', function () {
424
424
assert . ok ( scope . contains ( 'c' ) ) ;
425
425
} ) ;
426
426
427
+ it ( 'supports FunctionDeclarations without id' , function ( ) {
428
+ var ast = {
429
+ "type" : "Program" ,
430
+ "start" : 0 ,
431
+ "end" : 33 ,
432
+ "body" : [
433
+ {
434
+ "type" : "ExportDefaultDeclaration" ,
435
+ "start" : 0 ,
436
+ "end" : 32 ,
437
+ "declaration" : {
438
+ "type" : "FunctionDeclaration" ,
439
+ "start" : 15 ,
440
+ "end" : 32 ,
441
+ "id" : null ,
442
+ "generator" : false ,
443
+ "expression" : false ,
444
+ "async" : false ,
445
+ "params" : [ ] ,
446
+ "body" : {
447
+ "type" : "BlockStatement" ,
448
+ "start" : 26 ,
449
+ "end" : 32 ,
450
+ "body" : [ ]
451
+ }
452
+ }
453
+ }
454
+ ] ,
455
+ "sourceType" : "module"
456
+ } ;
457
+
458
+ var scope = attachScopes ( ast , 'scope' ) ;
459
+ // does not throw
460
+ } ) ;
461
+
427
462
// TODO more tests
428
463
} ) ;
429
464
You can’t perform that action at this time.
0 commit comments