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

Use before define from variables to classes. #131

Closed
vsmenon opened this issue Apr 10, 2015 · 4 comments
Closed

Use before define from variables to classes. #131

vsmenon opened this issue Apr 10, 2015 · 4 comments

Comments

@vsmenon
Copy link
Contributor

vsmenon commented Apr 10, 2015

This code (from Angular):

/// Marker for an uninitialized value.
const UNINITIALIZED = const _Uninitialized();
class _Uninitialized { const _Uninitialized(); }

is causing a runtime error on generated code as the use is before the define:

  let UNINITIALIZED = new _Uninitialized();
  class _Uninitialized extends core.Object {
    _Uninitialized() {
    }
  }
@jmesserly
Copy link
Contributor

this is basically #29, consts aren't implemented

@jmesserly
Copy link
Contributor

update, getting closer on this. The new design unifies all use-before-define concepts. It folds in the existing _lazyClass checks, without requiring duplication. It will also allow constants in method bodies to be hoisted out to the top-level (as an optimization, but also what a human would write in JS code).

@jmesserly
Copy link
Contributor

there's essentially two mechanisms:

  • ability to qualify identifiers later. In other words, exports.someName vs someName ... we don't know if we need this at first. The same mechanism should help ES6 module stuff too. (Basically, having to qualify names all the time is a drag.)
  • ability to reorder all top level "module items" on-the-fly. It still defaults to source order, but things can be filled in at different places if needed.

("module items" terminology is from https://people.mozilla.org/~jorendorff/es6-draft.html#sec-modules)

@jmesserly
Copy link
Contributor

https://codereview.chromium.org/1133593004/ ... finally :)

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