Skip to content

Commit

Permalink
fix circular member expression bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelly Selden committed Mar 6, 2018
1 parent 0856fe7 commit 6f9aeac
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ast/nodes/MemberExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default class MemberExpression extends NodeBase {
private arePropertyReadSideEffectsChecked: boolean;

bind() {
this.isBound = true;
const path = getPathIfNotComputed(this);
const baseVariable = path && this.scope.findVariable(path[0].key);
if (baseVariable && isNamespaceVariable(baseVariable)) {
Expand All @@ -86,7 +87,6 @@ export default class MemberExpression extends NodeBase {
} else {
this.bindChildren();
}
this.isBound = true;
}

private resolveNamespaceVariables(
Expand Down
3 changes: 3 additions & 0 deletions test/form/samples/circular-member-expression/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
description: 'circular member expression'
};
9 changes: 9 additions & 0 deletions test/form/samples/circular-member-expression/_expected/amd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
define(function () { 'use strict';

var foo = function() {
foo.toString = null;
}.toString();

console.log(foo);

});
7 changes: 7 additions & 0 deletions test/form/samples/circular-member-expression/_expected/cjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

var foo = function() {
foo.toString = null;
}.toString();

console.log(foo);
5 changes: 5 additions & 0 deletions test/form/samples/circular-member-expression/_expected/es.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var foo = function() {
foo.toString = null;
}.toString();

console.log(foo);
10 changes: 10 additions & 0 deletions test/form/samples/circular-member-expression/_expected/iife.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(function () {
'use strict';

var foo = function() {
foo.toString = null;
}.toString();

console.log(foo);

}());
14 changes: 14 additions & 0 deletions test/form/samples/circular-member-expression/_expected/system.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
System.register([], function (exports, module) {
'use strict';
return {
execute: function () {

var foo = function() {
foo.toString = null;
}.toString();

console.log(foo);

}
};
});
13 changes: 13 additions & 0 deletions test/form/samples/circular-member-expression/_expected/umd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';

var foo = function() {
foo.toString = null;
}.toString();

console.log(foo);

})));
5 changes: 5 additions & 0 deletions test/form/samples/circular-member-expression/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var foo = function() {
foo.toString = null;
}.toString();

console.log(foo);

0 comments on commit 6f9aeac

Please sign in to comment.