diff --git a/packages/syntax/babel_parser_suffix.js b/packages/syntax/babel_parser_suffix.js index aa630f2..5c76a24 100644 --- a/packages/syntax/babel_parser_suffix.js +++ b/packages/syntax/babel_parser_suffix.js @@ -1,5 +1,6 @@ -// Horrible, horrible, horrible, horrible hack to get hold of the Parser -// from babel-parser/src/parser/index.js. +// Horrible, horrible, horrible, horrible hack to get hold of (a) the +// Parser and (b) various flags and non-exported values from +// babel-parser/src/parser/index.js. exports._original_Parser = Parser; exports.__getParser = function () { @@ -8,3 +9,5 @@ exports.__getParser = function () { exports.__setParser = function (newParser) { Parser = newParser; }; + +exports.BIND_LEXICAL = BIND_LEXICAL; diff --git a/packages/syntax/src/parser.js b/packages/syntax/src/parser.js index c4bbb83..f1c13f6 100644 --- a/packages/syntax/src/parser.js +++ b/packages/syntax/src/parser.js @@ -16,7 +16,7 @@ // along with this program. If not, see . //--------------------------------------------------------------------------- -import { _original_Parser, tokTypes as tt } from "@babel/parser"; +import { _original_Parser, BIND_LEXICAL, tokTypes as tt } from "@babel/parser"; export default class SyndicateParser extends _original_Parser { // Overrides ExpressionParser.parseMaybeAssign @@ -141,6 +141,7 @@ export default class SyndicateParser extends _original_Parser { this.eatContextual("type"); if (!this.match(tt.name)) { this.unexpected(null, tt.name); } node.id = this.parseIdentifier(); + this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start); this.parseFunctionParams(node); // eww node.formals = node.params; delete node.params; // eww