question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing referencePaths after crawl

See original GitHub issue

Bug Report

  • I would like to work on a fix!

Current Behavior scope.crawl() does not add references to bindings correctly in some cases. In particular I get the bug when referencing a class inside a class method.

Input Code https://github.com/regiontog/babel/compare/master...bug/missing-references-after-crawl

const path = getPath("class a { build() { return new a(); } }");
path.scope.crawl();
const referencePaths = path.scope.bindings.a.referencePaths;
expect(referencePaths).toHaveLength(1);

Expected behavior/code I expect the binding a to have 1 reference inside the scope of the build class method after a crawl. The binding has 1 reference before the crawl call is made.

Environment

System:
    OS: Linux 5.4 Arch Linux
  Binaries:
    Node: 13.3.0 - /usr/bin/node
    Yarn: 1.21.0 - /usr/bin/yarn
    npm: 6.12.1 - /usr/bin/npm
  Monorepos:
    Lerna: 3.19.0
npmPackages:
    @babel/cli: ^7.7.0 => 7.7.5
    @babel/core: ^7.7.2 => 7.7.5
    @babel/eslint-plugin-development: ^1.0.1 => 1.0.1
    @babel/plugin-proposal-class-properties: ^7.7.0 => 7.7.4
    @babel/plugin-proposal-export-namespace-from: ^7.5.2 => 7.7.4
    @babel/plugin-proposal-nullish-coalescing-operator: ^7.4.4 => 7.7.4
    @babel/plugin-proposal-numeric-separator: ^7.2.0 => 7.7.4
    @babel/plugin-proposal-object-rest-spread: ^7.7.4 => 7.7.4
    @babel/plugin-proposal-optional-chaining: ^7.6.0 => 7.7.5
    @babel/plugin-transform-flow-strip-types: ^7.7.4 => 7.7.4
    @babel/plugin-transform-for-of: ^7.7.4 => 7.7.4
    @babel/plugin-transform-modules-commonjs: ^7.7.0 => 7.7.5
    @babel/plugin-transform-runtime: ^7.6.2 => 7.7.6
    @babel/preset-env: ^7.7.1 => 7.7.6
    @babel/preset-flow: ^7.0.0 => 7.7.4
    @babel/register: ^7.7.0 => 7.7.4
    @babel/runtime: ^7.7.2 => 7.7.6
    babel-eslint: ^11.0.0-beta.2 => 11.0.0-beta.2
    babel-jest: ^24.9.0 => 24.9.0
    babel-plugin-transform-charcodes: ^0.2.0 => 0.2.0
    eslint: ^6.0.1 => 6.7.2
    eslint-config-babel: ^9.0.0 => 9.0.0
    gulp-babel: ^8.0.0 => 8.0.0
    jest: ^24.9.0 => 24.9.0
    lerna: ^3.19.0 => 3.19.0
    rollup-plugin-babel: ^4.0.0 => 4.3.3
  • How you are using Babel: API

Possible Solution

It seems suspect to me to add the reference to a binding in the references own scope here

Additional context/Screenshots Output of test linked above:

scope › binding paths › reference paths after crawl

    expect(received).toHaveLength(expected)

    Expected length: 1
    Received length: 0
    Received array:  []

      276 |       path.scope.crawl();
      277 |       const referencePaths = path.scope.bindings.a.referencePaths;
    > 278 |       expect(referencePaths).toHaveLength(1);
          |                              ^
      279 |     });
      280 |   });
      281 |

      at Object.<anonymous> (packages/babel-traverse/test/scope.js:278:30)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
mischniccommented, Jan 11, 2020

I’ll close my old issue https://github.com/babel/babel/issues/9327 as a duplicate.

2reactions
existentialismcommented, Jan 10, 2020

@JLHwung sidenote, fantastic explanation 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot broken references - Visual Studio - Microsoft Learn
To fix a broken project reference by correcting the reference path ... In Solution Explorer, right-click your project node, and then select ...
Read more >
Are you missing an assembly reference? Why, yes I am. So ...
Solution #2: Empower NuGet to Self-Heal​​ Select the “Enable NuGet Package Restore” menu to bring up the NuGet management dialog. Click on “ ......
Read more >
About Displaying Missing References - PTC Support
Following an Existing Pipeline · Non Specification-Driven Piping Flow Direction · To Display or Reverse the Flow Direction of a Pipeline.
Read more >
Setting crawler configuration options - AWS Glue
Learn about how to configure what a crawler does when it encounters schema changes and partition changes in your data store.
Read more >
Why is my page missing from Google Search?
Troubleshooting missing pages and sitesHere's how to troubleshoot and fix the ... post a new page before we crawl it, and more time...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found