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

圧縮時に変数名がダブってしまう #29

Open
slofp opened this issue Jan 22, 2024 · 1 comment
Open

圧縮時に変数名がダブってしまう #29

slofp opened this issue Jan 22, 2024 · 1 comment
Labels
bug Something isn't working project/Lib Ai.js main source issue

Comments

@slofp
Copy link
Owner

slofp commented Jan 22, 2024

classを定義したときに、コンストラクタが変換時に関数になる仕様上terserが想定していない動きになってしまっている

例えば

function create(x) {
  return x;
}
class A {
  constructor(vv) {
    this.vv = vv;
    this.w = this.getW();
  }
  getW() {
    return create(this.vv);
  }
}

としたとき、

function a(x) {
  return x;
}
class A {
  constructor(a) {
    this.a = a;
    this.b = this.c();
  }
  getW() {
    return a(this.a);
  }
}

この様になるため、javascript上では問題なく動作するが、変換の都合上コンストラクタのaと関数のaが重複してしまいローカルスコープが参照されるため実行エラーになる。

@slofp slofp added bug Something isn't working project/Lib Ai.js main source issue labels Jan 22, 2024
@slofp
Copy link
Owner Author

slofp commented Jan 23, 2024

classの生成方法を変えたほうがいいかもしれない

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working project/Lib Ai.js main source issue
Projects
None yet
Development

No branches or pull requests

1 participant