File tree 2 files changed +23
-1
lines changed
2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -420,7 +420,9 @@ export default class Referencer extends esrecurse.Visitor {
420
420
421
421
ContinueStatement ( ) { }
422
422
423
- LabeledStatement ( ) { }
423
+ LabeledStatement ( node ) {
424
+ this . visit ( node . body ) ;
425
+ }
424
426
425
427
ForStatement ( node ) {
426
428
// Create ForStatement declaration.
Original file line number Diff line number Diff line change @@ -47,4 +47,24 @@ describe 'label', ->
47
47
expect (scope .isArgumentsMaterialized ()).to .be .false
48
48
expect (scope .references ).to .have .length 0
49
49
50
+ it ' should count child node references' , ->
51
+ ast = esprima .parse """
52
+ var foo = 5;
53
+
54
+ label: while (true) {
55
+ console.log(foo);
56
+ break;
57
+ }
58
+ """
59
+
60
+ scopeManager = escope .analyze ast
61
+ expect (scopeManager .scopes ).to .have .length 1
62
+ globalScope = scopeManager .scopes [0 ]
63
+ expect (globalScope .type ).to .be .equal ' global'
64
+ expect (globalScope .variables ).to .have .length 1
65
+ expect (globalScope .variables [0 ].name ).to .be .equal ' foo'
66
+ expect (globalScope .through .length ).to .be .equal 3
67
+ expect (globalScope .through [2 ].identifier .name ).to .be .equal ' foo'
68
+ expect (globalScope .through [2 ].isRead ()).to .be .true
69
+
50
70
# vim: set sw=4 ts=4 et tw=80 :
You can’t perform that action at this time.
0 commit comments