Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mod(es/base): Stable context for unresolved and global #7096

Merged
merged 1 commit into from Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions bindings/binding_core_wasm/__tests__/simple.js
Expand Up @@ -108,7 +108,7 @@ describe("parse", () => {
"identifier": Object {
"optional": false,
"span": Object {
"ctxt": 1,
"ctxt": 2,
"end": 394,
"start": 391,
},
Expand Down Expand Up @@ -155,7 +155,7 @@ describe("parse", () => {
"identifier": Object {
"optional": false,
"span": Object {
"ctxt": 1,
"ctxt": 2,
"end": 407,
"start": 404,
},
Expand Down
Expand Up @@ -11,7 +11,7 @@
//// [index.js]
/**
* @typedef {import("./externs")} Foo
*/ let a = /** @type {*} */ undefined;
*/ let a = /** @type {Foo} */ /** @type {*} */ undefined;
a = new Foo({
doer: Foo.Bar
});
Expand Down
3 changes: 3 additions & 0 deletions crates/swc_ecma_transforms_base/src/resolver/mod.rs
Expand Up @@ -141,6 +141,9 @@ pub fn resolver(
"Marker provided to resolver should not be the root mark"
);

let _ = SyntaxContext::empty().apply_mark(unresolved_mark);
let _ = SyntaxContext::empty().apply_mark(top_level_mark);

as_folder(Resolver {
current: Scope::new(ScopeKind::Fn, top_level_mark, None),
ident_type: IdentType::Ref,
Expand Down
@@ -1,6 +1,6 @@
let arr__1 = [];
for(let i__2 = 0; i__2 < 10; i__2++){
for(let i__4 = 0; i__4 < 10; i__4++){
arr__1.push(()=>i__4);
let arr__2 = [];
for(let i__3 = 0; i__3 < 10; i__3++){
for(let i__5 = 0; i__5 < 10; i__5++){
arr__2.push(()=>i__5);
}
}
@@ -1,8 +1,8 @@
{
var foo__1 = 1;
var foo__2 = 1;
{
let foo__3 = 2;
use(foo__3);
let foo__4 = 2;
use(foo__4);
}
use(foo__1);
use(foo__2);
}
@@ -1,4 +1,4 @@
let foo__1;
let foo__2;
{
let foo__2;
let foo__3;
}
@@ -1,9 +1,9 @@
const g__1 = 20;
function baz__1() {
const g__2 = 20;
function baz__2() {
{
class g__3 {
class g__4 {
}
console.log(g__3);
console.log(g__4);
}
return g__1;
return g__2;
}
@@ -1,5 +1,5 @@
var Foo__1 = function(_Bar__2) {
_inherits(Foo__2, _Bar__2);
function Foo__2() {}
return Foo__2;
var Foo__2 = function(_Bar__3) {
_inherits(Foo__3, _Bar__3);
function Foo__3() {}
return Foo__3;
}(Bar);
@@ -1,5 +1,5 @@
var Foo__1 = function(_Bar__2) {
_inherits(Foo__2, _Bar__2);
function Foo__2() {}
return Foo__2;
var Foo__2 = function(_Bar__3) {
_inherits(Foo__3, _Bar__3);
function Foo__3() {}
return Foo__3;
}(Bar);
@@ -1,7 +1,7 @@
let Test__1 = 2;
let Test__2 = 2;
test(class Test__3 {
hi() {
console.log(Test__3);
}
});
Test__1 = 4;
Test__2 = 4;
@@ -1,15 +1,15 @@
var Outer__1 = function(_Hello__2) {
_inherits(Outer__2, _Hello__2);
function Outer__2() {
_classCallCheck(this, Outer__2);
var _this__4 = _possibleConstructorReturn(this, _getPrototypeOf(Outer__2).call(this));
var Outer__2 = function(_Hello__3) {
_inherits(Outer__3, _Hello__3);
function Outer__3() {
_classCallCheck(this, Outer__3);
var _this__4 = _possibleConstructorReturn(this, _getPrototypeOf(Outer__3).call(this));
var Inner__4 = function() {
function Inner__5() {
_classCallCheck(this, Inner__5);
}
_createClass(Inner__5, [
{
key: _get(_getPrototypeOf(Outer__2.prototype), "toString", _assertThisInitialized(_this__4)).call(_this__4),
key: _get(_getPrototypeOf(Outer__3.prototype), "toString", _assertThisInitialized(_this__4)).call(_this__4),
value: function() {
return "hello";
}
Expand All @@ -19,5 +19,5 @@ var Outer__1 = function(_Hello__2) {
}();
return _possibleConstructorReturn(_this__4, new Inner__4());
}
return Outer__2;
return Outer__3;
}(Hello);
@@ -1,6 +1,6 @@
var ConstructorScoping__1 = function ConstructorScoping__2() {
_classCallCheck(this, ConstructorScoping__2);
var bar__3;
var ConstructorScoping__2 = function ConstructorScoping__3() {
_classCallCheck(this, ConstructorScoping__3);
var bar__4;
{
let bar__5;
use(bar__5);
Expand Down
@@ -1,14 +1,14 @@
var singleton__1;
var Sub__1 = function(_Foo__2) {
_inherits(Sub__2, _Foo__2);
function Sub__2() {
var singleton__2;
var Sub__2 = function(_Foo__3) {
_inherits(Sub__3, _Foo__3);
function Sub__3() {
var _this__4;
_classCallCheck(this, Sub__2);
if (singleton__1) {
return _possibleConstructorReturn(_this__4, singleton__1);
_classCallCheck(this, Sub__3);
if (singleton__2) {
return _possibleConstructorReturn(_this__4, singleton__2);
}
singleton__1 = _this__4 = _possibleConstructorReturn(this, _getPrototypeOf(Sub__2).call(this));
singleton__2 = _this__4 = _possibleConstructorReturn(this, _getPrototypeOf(Sub__3).call(this));
return _possibleConstructorReturn(_this__4);
}
return Sub__2;
return Sub__3;
}(Foo);
@@ -1,8 +1,8 @@
function foo__1() {
const sym__2 = "dasdas";
return class Bar__3 extends Foo {
[sym__2]() {
return super[sym__2]() + super.sym();
function foo__2() {
const sym__3 = "dasdas";
return class Bar__4 extends Foo {
[sym__3]() {
return super[sym__3]() + super.sym();
}
};
}
@@ -1,10 +1,10 @@
var Foo__1 = function(_Bar__2) {
_inherits(Foo__2, _Bar__2);
function Foo__2() {
var Foo__2 = function(_Bar__3) {
_inherits(Foo__3, _Bar__3);
function Foo__3() {
var _this__4;
_classCallCheck(this, Foo__2);
Foo__2[_assertThisInitialized(_this__4)];
_classCallCheck(this, Foo__3);
Foo__3[_assertThisInitialized(_this__4)];
return _possibleConstructorReturn(_this__4);
}
return Foo__2;
return Foo__3;
}(Bar);
@@ -1 +1 @@
var Foo__1 = function Foo__2() {};
var Foo__2 = function Foo__3() {};
@@ -1,7 +1,7 @@
const b__1 = 1;
const b1__1 = 2;
const b__2 = 1;
const b1__2 = 2;
{
const b__2 = 3;
const b1__2 = 4;
const b2__2 = 5;
const b__3 = 3;
const b1__3 = 4;
const b2__3 = 5;
}
@@ -1,12 +1,12 @@
var ___1 = 1;
function wt__1(e__2, n__2, t__2, r__2) {
var l__2 = e__2.updateQueue;
var ___2 = 1;
function wt__2(e__3, n__3, t__3, r__3) {
var l__3 = e__3.updateQueue;
if (u !== null) {
if (y !== null) {
var ___2 = y.lastBaseUpdate;
var ___3 = y.lastBaseUpdate;
}
}
if (i !== null) {
___2 = l__2.baseState, o = 0, y = d = s = null;
___3 = l__3.baseState, o = 0, y = d = s = null;
}
}
@@ -1,11 +1,11 @@
var ___1 = 1;
function wt__1() {
var ___2 = 1;
function wt__2() {
if (u !== null) {
if (y !== null) {
var ___2 = 2;
var ___3 = 2;
}
}
if (i !== null) {
___2 = 3;
___3 = 3;
}
}
@@ -1,7 +1,7 @@
export default class Test__1 {
export default class Test__2 {
hi() {
let Test__2 = 2;
console.log(Test__2);
let Test__3 = 2;
console.log(Test__3);
}
}
Test__1 = 2;
Test__2 = 2;
@@ -1,7 +1,7 @@
export default function foo__1() {
foo__1 = function foo__3(x__4) {
return x__4 === 0 ? 1 : 1 + foo__3(x__4 - 1);
export default function foo__2() {
foo__2 = function foo__4(x__5) {
return x__5 === 0 ? 1 : 1 + foo__4(x__5 - 1);
};
return foo__1(10);
return foo__2(10);
}
foo__1 = 2;
foo__2 = 2;
@@ -1,6 +1,6 @@
test(function foo__2() {
foo__2 = function foo__4(x__5) {
return x__5 === 0 ? 1 : 1 + foo__4(x__5 - 1);
test(function foo__3() {
foo__3 = function foo__5(x__6) {
return x__6 === 0 ? 1 : 1 + foo__5(x__6 - 1);
};
return foo__2(10);
return foo__3(10);
});
@@ -1,11 +1,11 @@
var k__1, v__1;
var map__1 = new Map([
var k__2, v__2;
var map__2 = new Map([
[
"",
true
]
]);
for ([k__1, ...[v__1]] of map__1){
k__1;
v__1;
for ([k__2, ...[v__2]] of map__2){
k__2;
v__2;
}
@@ -1,5 +1,5 @@
let a__1 = "foo";
function foo__1() {
let a__2 = "bar";
use(a__2);
let a__2 = "foo";
function foo__2() {
let a__3 = "bar";
use(a__3);
}
@@ -1,13 +1,13 @@
function foo__1() {
const r__2 = ()=>1;
function foo__2() {
const r__3 = ()=>1;
if (true) {
function r__3() {
function r__4() {
return 2;
}
}
console.log(r__2());
console.log(r__3());
}
function bar__1() {
function bar__2() {
var r__6 = ()=>1;
if (true) {
function r__6() {
Expand All @@ -16,7 +16,7 @@ function bar__1() {
}
console.log(r__6());
}
function baz__1() {
function baz__2() {
function r__9() {
return 1;
}
Expand All @@ -27,7 +27,7 @@ function baz__1() {
}
console.log(r__9());
}
function quz__1(r__13 = ()=>1) {
function quz__2(r__13 = ()=>1) {
if (true) {
function r__14() {
return 2;
Expand Down
@@ -1,4 +1,4 @@
let a__1 = "foo";
function foo__1(a__2) {
use(a__2);
let a__2 = "foo";
function foo__2(a__3) {
use(a__3);
}
@@ -1,12 +1,12 @@
const foo__1 = "foo";
function foobar__1() {
for (let item__3 of [
const foo__2 = "foo";
function foobar__2() {
for (let item__4 of [
1,
2,
3
]){
let foo__4 = "bar";
[bar, foo__4] = [
let foo__5 = "bar";
[bar, foo__5] = [
1,
2
];
Expand Down
@@ -1,3 +1,3 @@
function test__1() {
let foo__2 = "bar";
function test__2() {
let foo__3 = "bar";
}
@@ -1,3 +1,3 @@
function foo__1(Object__2) {
Object__2.defineProperty();
function foo__2(Object__3) {
Object__3.defineProperty();
}