microsoft / microsoft/TypeScript-TmLanguage

TextMate tokenizer enters incorrect scope after typeof a < "u" in JavaScript, affecting subsequent function declarations

オープン
#1,076 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
TypeScript
スター
471
フォーク
149
PR マージ指標
30日以内にマージされた PR はありません

説明

VS Code Version

Version: 1.124.2 (user setup)
Commit: 6928394f91b684055b873eecb8bc281365131f1c
Date: 2026-06-12T00:12:36Z
Electron: 42.2.0
ElectronBuildId: 14159160
Chromium: 148.0.7778.97
Node.js: 24.15.0
V8: 14.8.178.14-electron.0
OS: Windows_NT x64 10.0.26200

Fresh install of VS Code with all default settings. No extensions installed, no custom configuration applied.
Also reproduced on VS Code for the Web (vscode.dev) with no extensions or custom configuration.

Reproducible Example

function bar() {
  return "bar";
}

var a = typeof a < "u";

function foo() {
  return "foo";
}

Steps to Reproduce

  1. Install VS Code with all default settings (no extensions, no custom configuration).
  2. Create a new .js file.
  3. Paste the code above.
  4. Run:
Developer: Inspect Editor Tokens and Scopes
  1. Inspect the first function keyword (bar declaration).
  2. Inspect the second function keyword (foo declaration).

Actual Result

The first function declaration is tokenized correctly:

storage.type.function.js
meta.function.js
source.js

The second function declaration is tokenized incorrectly:

entity.name.type.js
meta.type.parameters.js
meta.var.expr.js
source.js

Syntax highlighting becomes incorrect for all code following:

var a = typeof a < "u";

Expected Result

The second function declaration should receive the same scopes as the first:

storage.type.function.js
meta.function.js
source.js

No tokenizer state should leak past the end of the variable declaration.

Additional Investigation

Replacing:

var a = typeof a < "u";

with:

var a = typeof a > "u";
Image immediately fixes the issue. The second `function` is then correctly scoped as:

Notes

  • Reproduced on a fresh VS Code install with all default settings and no extensions.
  • Reproduced across all built-in themes; the issue is not theme-specific.
  • The JavaScript is syntactically valid.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、JavaScript ファイルで例を再現し、「Developer: Inspect Editor Tokens and Scopes」を使用して2つの関数宣言を比較します。typeof a < "u" とその後の宣言を処理する TextMate 文法のルールを追跡します。完了条件は、2つ目の関数が1つ目と同じ scopes を受け取り、tokenizer の状態が後続のコードに漏れなくなることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, typescript
領域
tooling
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
68/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。