This repository was archived by the owner on Aug 4, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ class Scope {
61
61
// it's a `var` or function node, and this
62
62
// is a block scope, so we need to go up
63
63
this . parent . addDeclaration ( node , isBlockDeclaration , isVar ) ;
64
- } else {
64
+ } else if ( node . id ) {
65
65
extractNames ( node . id ) . forEach ( name => {
66
66
this . declarations [ name ] = true ;
67
67
} ) ;
Original file line number Diff line number Diff line change @@ -177,6 +177,41 @@ describe( 'rollup-pluginutils', function () {
177
177
assert . ok ( scope . contains ( 'bar' ) ) ;
178
178
} ) ;
179
179
180
+ it ( 'supports FunctionDeclarations without id' , function ( ) {
181
+ var ast = {
182
+ "type" : "Program" ,
183
+ "start" : 0 ,
184
+ "end" : 33 ,
185
+ "body" : [
186
+ {
187
+ "type" : "ExportDefaultDeclaration" ,
188
+ "start" : 0 ,
189
+ "end" : 32 ,
190
+ "declaration" : {
191
+ "type" : "FunctionDeclaration" ,
192
+ "start" : 15 ,
193
+ "end" : 32 ,
194
+ "id" : null ,
195
+ "generator" : false ,
196
+ "expression" : false ,
197
+ "async" : false ,
198
+ "params" : [ ] ,
199
+ "body" : {
200
+ "type" : "BlockStatement" ,
201
+ "start" : 26 ,
202
+ "end" : 32 ,
203
+ "body" : [ ]
204
+ }
205
+ }
206
+ }
207
+ ] ,
208
+ "sourceType" : "module"
209
+ } ;
210
+
211
+ var scope = attachScopes ( ast , 'scope' ) ;
212
+ // does not throw
213
+ } ) ;
214
+
180
215
// TODO more tests
181
216
} ) ;
182
217
You can’t perform that action at this time.
0 commit comments