Fixing code generation.

This commit is contained in:
Nikolai Tillmann 2017-04-25 15:31:31 -07:00 committed by Nikolai Tillmann
parent fb9272da50
commit ab51aa2b5e
2 changed files with 11 additions and 1 deletions

View File

@ -284,7 +284,7 @@ export class PreludeGenerator {
globalReference(key: string, globalScope: boolean = false) { globalReference(key: string, globalScope: boolean = false) {
if (globalScope && t.isValidIdentifier(key)) return t.identifier(key); if (globalScope && t.isValidIdentifier(key)) return t.identifier(key);
let keyNode = t.isValidIdentifier(key) ? t.identifier(key) : t.stringLiteral(key); let keyNode = t.isValidIdentifier(key) ? t.identifier(key) : t.stringLiteral(key);
return t.memberExpression(this.memoizeReference("::global"), keyNode); return t.memberExpression(this.memoizeReference("::global"), keyNode, !t.isIdentifier(keyNode));
} }
memoizeReference(key: string): BabelNodeIdentifier | BabelNodeMemberExpression | BabelNodeThisExpression { memoizeReference(key: string): BabelNodeIdentifier | BabelNodeMemberExpression | BabelNodeThisExpression {

View File

@ -0,0 +1,10 @@
(function() {
function bar() {
try {
return _0.name;
} catch(e) {
return "exception";
}
}
inspect = function() { return bar(); }
})();