diff --git a/lib/6to5/transformation/transform.js b/lib/6to5/transformation/transform.js
index 8cb1e02098..e9153224e8 100644
--- a/lib/6to5/transformation/transform.js
+++ b/lib/6to5/transformation/transform.js
@@ -52,6 +52,7 @@ _.each({
"spec.noForInOfAssignment": require("./transformers/spec/no-for-in-of-assignment"),
"spec.setters": require("./transformers/spec/setters"),
"spec.blockScopedFunctions": require("./transformers/spec/block-scoped-functions"),
+ "spec.illegalTopLevelThis": require("./transformers/spec/illegal-top-level-this"),
"playground.malletOperator": require("./transformers/playground/mallet-operator"),
"playground.methodBinding": require("./transformers/playground/method-binding"),
diff --git a/lib/6to5/transformation/transformers/spec/illegal-top-level-this.js b/lib/6to5/transformation/transformers/spec/illegal-top-level-this.js
new file mode 100644
index 0000000000..e1edc90c31
--- /dev/null
+++ b/lib/6to5/transformation/transformers/spec/illegal-top-level-this.js
@@ -0,0 +1,8 @@
+exports.FunctionDeclaration =
+exports.FunctionExpression = function (node, parent, scope, context) {
+ context.skip();
+};
+
+exports.ThisExpression = function (node, parent, scope, context, file) {
+ throw file.errorWithNode(node, "Top level `this` is not allowed", ReferenceError);
+};
diff --git a/test/fixtures/transformation/es6-arrow-functions/this/actual.js b/test/fixtures/transformation/es6-arrow-functions/this/actual.js
index 8e2573dd1f..3175c884d0 100644
--- a/test/fixtures/transformation/es6-arrow-functions/this/actual.js
+++ b/test/fixtures/transformation/es6-arrow-functions/this/actual.js
@@ -1 +1,3 @@
-var t = x => this.x + x;
+function b() {
+ var t = x => this.x + x;
+}
diff --git a/test/fixtures/transformation/es6-arrow-functions/this/expected.js b/test/fixtures/transformation/es6-arrow-functions/this/expected.js
index 5206629491..358e3710a3 100644
--- a/test/fixtures/transformation/es6-arrow-functions/this/expected.js
+++ b/test/fixtures/transformation/es6-arrow-functions/this/expected.js
@@ -1,6 +1,8 @@
"use strict";
-var _this = this;
-var t = function (x) {
- return _this.x + x;
-};
+function b() {
+ var _this = this;
+ var t = function (x) {
+ return _this.x + x;
+ };
+}
diff --git a/test/fixtures/transformation/es6-destructuring/for-of/actual.js b/test/fixtures/transformation/es6-destructuring/for-of/actual.js
index 5873553d65..d8aae78557 100644
--- a/test/fixtures/transformation/es6-destructuring/for-of/actual.js
+++ b/test/fixtures/transformation/es6-destructuring/for-of/actual.js
@@ -1,3 +1,3 @@
-for (var [ name, before, after ] of this.test.expectation.registers) {
+for (var [ name, before, after ] of test.expectation.registers) {
}
diff --git a/test/fixtures/transformation/es6-destructuring/for-of/expected.js b/test/fixtures/transformation/es6-destructuring/for-of/expected.js
index f29c5c92ea..d564f1bf2b 100644
--- a/test/fixtures/transformation/es6-destructuring/for-of/expected.js
+++ b/test/fixtures/transformation/es6-destructuring/for-of/expected.js
@@ -16,7 +16,7 @@ var _slicedToArray = function (arr, i) {
}
};
-for (var _iterator = this.test.expectation.registers[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
+for (var _iterator = test.expectation.registers[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
var _step$value = _slicedToArray(_step.value, 3);
var name = _step$value[0];
diff --git a/test/fixtures/transformation/es6-destructuring/member-expression/actual.js b/test/fixtures/transformation/es6-destructuring/member-expression/actual.js
index bd5e42d7d1..8d8bc57855 100644
--- a/test/fixtures/transformation/es6-destructuring/member-expression/actual.js
+++ b/test/fixtures/transformation/es6-destructuring/member-expression/actual.js
@@ -1 +1 @@
-[this.foo, this.bar] = [1, 2];
+[foo.foo, foo.bar] = [1, 2];
diff --git a/test/fixtures/transformation/es6-destructuring/member-expression/expected.js b/test/fixtures/transformation/es6-destructuring/member-expression/expected.js
index fbaaa04184..30b475cb11 100644
--- a/test/fixtures/transformation/es6-destructuring/member-expression/expected.js
+++ b/test/fixtures/transformation/es6-destructuring/member-expression/expected.js
@@ -20,5 +20,5 @@ var _ref = [1, 2];
var _ref2 = _slicedToArray(_ref, 2);
-this.foo = _ref2[0];
-this.bar = _ref2[1];
+foo.foo = _ref2[0];
+foo.bar = _ref2[1];
diff --git a/test/fixtures/transformation/es6-properties.computed-loose/this/actual.js b/test/fixtures/transformation/es6-properties.computed-loose/this/actual.js
index 3e3a34ef12..ebaed8a961 100644
--- a/test/fixtures/transformation/es6-properties.computed-loose/this/actual.js
+++ b/test/fixtures/transformation/es6-properties.computed-loose/this/actual.js
@@ -1,3 +1,3 @@
var obj = {
- ["x" + this.foo]: "heh"
+ ["x" + foo.bar]: "heh"
};
diff --git a/test/fixtures/transformation/es6-properties.computed-loose/this/expected.js b/test/fixtures/transformation/es6-properties.computed-loose/this/expected.js
index 23b5ee17e4..c89572a402 100644
--- a/test/fixtures/transformation/es6-properties.computed-loose/this/expected.js
+++ b/test/fixtures/transformation/es6-properties.computed-loose/this/expected.js
@@ -1,9 +1,8 @@
"use strict";
-var _this = this;
var obj = (function () {
var _obj = {};
- _obj["x" + _this.foo] = "heh";
+ _obj["x" + foo.foo] = "heh";
return _obj;
-})();
\ No newline at end of file
+})();
diff --git a/test/fixtures/transformation/es6-properties.computed/this/actual.js b/test/fixtures/transformation/es6-properties.computed/this/actual.js
index 3e3a34ef12..ebaed8a961 100644
--- a/test/fixtures/transformation/es6-properties.computed/this/actual.js
+++ b/test/fixtures/transformation/es6-properties.computed/this/actual.js
@@ -1,3 +1,3 @@
var obj = {
- ["x" + this.foo]: "heh"
+ ["x" + foo.bar]: "heh"
};
diff --git a/test/fixtures/transformation/es6-properties.computed/this/expected.js b/test/fixtures/transformation/es6-properties.computed/this/expected.js
index 3c3334e470..7f573491fd 100644
--- a/test/fixtures/transformation/es6-properties.computed/this/expected.js
+++ b/test/fixtures/transformation/es6-properties.computed/this/expected.js
@@ -9,4 +9,4 @@ var _defineProperty = function (obj, key, value) {
});
};
-var obj = _defineProperty({}, "x" + this.foo, "heh");
+var obj = _defineProperty({}, "x" + foo.bar, "heh");
diff --git a/test/fixtures/transformation/react/adds-appropriate-newlines-when-using-spread-attribute/actual.js b/test/fixtures/transformation/react/adds-appropriate-newlines-when-using-spread-attribute/actual.js
index 88ca6d7a77..2c800f1558 100644
--- a/test/fixtures/transformation/react/adds-appropriate-newlines-when-using-spread-attribute/actual.js
+++ b/test/fixtures/transformation/react/adds-appropriate-newlines-when-using-spread-attribute/actual.js
@@ -1,3 +1,3 @@