Skip to content

Commit c9fce90

Browse files
committed
Fix scope for nested empty function expressions
1 parent d567958 commit c9fce90

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

lib/node_modules/@stdlib/_tools/js/program-summary/lib/analyze.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ function analyze( results, ast, src, lines, scope, opts ) {
8585
res.type = 'expression';
8686
res.name = ( node.id ) ? node.id.name : '(anonymous)';
8787
res.params = node.params.length;
88+
res.scope = scope;
8889

8990
// Cache the sub-tree results:
9091
results[ key ].data.push( res );

lib/node_modules/@stdlib/_tools/js/program-summary/test/fixtures/nested_function_expressions.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"empty": 0,
7171
"sloc": 0,
7272
"lloc": 0,
73-
"scope": 0,
73+
"scope": 3,
7474
"comments": {
7575
"count": 0,
7676
"length": 0,
@@ -207,7 +207,7 @@
207207
"empty": 0,
208208
"sloc": 0,
209209
"lloc": 0,
210-
"scope": 0,
210+
"scope": 3,
211211
"comments": {
212212
"count": 0,
213213
"length": 0,
@@ -350,7 +350,7 @@
350350
"empty": 0,
351351
"sloc": 0,
352352
"lloc": 0,
353-
"scope": 0,
353+
"scope": 3,
354354
"comments": {
355355
"count": 0,
356356
"length": 0,
@@ -487,7 +487,7 @@
487487
"empty": 0,
488488
"sloc": 0,
489489
"lloc": 0,
490-
"scope": 0,
490+
"scope": 3,
491491
"comments": {
492492
"count": 0,
493493
"length": 0,
@@ -636,7 +636,7 @@
636636
"empty": 0,
637637
"sloc": 0,
638638
"lloc": 0,
639-
"scope": 0,
639+
"scope": 3,
640640
"comments": {
641641
"count": 0,
642642
"length": 0,
@@ -773,7 +773,7 @@
773773
"empty": 0,
774774
"sloc": 0,
775775
"lloc": 0,
776-
"scope": 0,
776+
"scope": 3,
777777
"comments": {
778778
"count": 0,
779779
"length": 0,
@@ -916,7 +916,7 @@
916916
"empty": 0,
917917
"sloc": 0,
918918
"lloc": 0,
919-
"scope": 0,
919+
"scope": 3,
920920
"comments": {
921921
"count": 0,
922922
"length": 0,
@@ -1053,7 +1053,7 @@
10531053
"empty": 0,
10541054
"sloc": 0,
10551055
"lloc": 0,
1056-
"scope": 0,
1056+
"scope": 3,
10571057
"comments": {
10581058
"count": 0,
10591059
"length": 0,

0 commit comments

Comments
 (0)