Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Variable names and library names can conflict #157

Closed
vsmenon opened this issue Apr 24, 2015 · 2 comments
Closed

Variable names and library names can conflict #157

vsmenon opened this issue Apr 24, 2015 · 2 comments

Comments

@vsmenon
Copy link
Contributor

vsmenon commented Apr 24, 2015

I'm hitting an error in generated code where a local variable name is shadowing a global library name:

    instantiate(key) {
      let binding = this.injector[_getBinding](key);
      if (lang.isBlank(binding))
        return exports[_notFound];
      this.injector[_markAsConstructing](key);
      let deps = this.injector[_resolveDependencies](key, dart.as(binding, binding.Binding), true);

In particular, in:

dart.as(binding, binding.Binding)

The first binding should be the local var, and the second should be the binding library.

@jmesserly
Copy link
Contributor

Yeah, one of the things it would be nice to address as part of a ES6 modules story.

What's happening is our "module pattern" is introducing names into the user's scope that were not supposed to be there (in the original Dart code)

Renaming the local is tempting, however, I think that's probably the wrong approach, because the local should have the debugger friendly name. It's the qualified module name that is the compiler-generated variable. Or even better: avoid qualifying when possible**, such as in this case. Instead import the names that are used.

(** qualification is required for lazy statics though)

@jmesserly jmesserly self-assigned this May 5, 2015
@jmesserly
Copy link
Contributor

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants