microsoft / microsoft/TypeScript
`eval?.()` is now an indirect eval
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
Bug Report
There has apparently been a recent change to the behavior of eval?.() in all major JavaScript engines. It is now considered an indirect eval instead of a direct eval. This behavior was changed in July 2020. TypeScript is still compiling it as a direct eval and I didn't see an issue about this, so I created this issue.
More context: https://bugs.chromium.org/p/v8/issues/detail?id=10630
🔎 Search Terms
optional chain direct indirect eval scope
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
Playground link with relevant code
💻 Code
globalThis.a = "global";
(a => eval?.("console.log(a)"))("local");
🙁 Actual behavior
When compiled with TypeScript, this prints local instead. That matches the behavior of older JavaScript runtimes such as node v14 but doesn't match the latest JavaScript runtimes.
🙂 Expected behavior
This code now prints global when run in an up-to-date browser or in node v15, so it should print global when compiled with TypeScript as well.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された Playground の例を最新の JavaScript ランタイムでコンパイルして実行し、生成された JavaScript を報告されたグローバル対ローカルの結果と比較します。payload にはソースファイルやテストの名前がないため、オプショナルコール式を処理するコンパイラパスを特定し、間接 eval の期待される動作を示すカバレッジを追加します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 35/100