From 7072acea8299b2a91ad839b8258e1502bbc3a2e8 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Wed, 28 Oct 2026 15:19:08 +0800 Subject: [PATCH] =?UTF-8?q?test(lsp):=20=E8=A6=86=E7=9B=96=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=AD=97=E9=9D=A2=E9=87=8F=E5=90=8E=E6=BA=A2=E5=87=BA?= =?UTF-8?q?=E8=AF=8A=E6=96=AD=E6=B8=85=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gate2 在 push 与 pull 两条路径上都验证:把超长字面量改成 1 后诊断必须清空,防止词法错误状态串到下一次解析。 --- Tools/lsp/probe.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Tools/lsp/probe.py b/Tools/lsp/probe.py index 63165cd..826e4bc 100644 --- a/Tools/lsp/probe.py +++ b/Tools/lsp/probe.py @@ -422,6 +422,18 @@ def gate2(exe: str) -> int: functions = {(t["line"], t["character"]) for t in sem_tokens if t["type"] == function_type} if (0, 4) not in functions or (3, 4) not in functions: raise AssertionError(f"semantic tokens lost after a lexer error: {sem_tokens}") + # Fixing the literal must clear the overflow diagnostic (lexer fail-fast state is global and + # must be reset for the next parse, otherwise the stale error sticks to every later edit). + fixed_overflow = overflow.replace("1024000000000000000000", "1") + client.notify( + "textDocument/didChange", + {"textDocument": {"uri": uri, "version": 4}, + "contentChanges": [{"text": fixed_overflow}]}, + ) + publish = client.wait_notification("textDocument/publishDiagnostics") + diagnostics = publish.get("params", {}).get("diagnostics") + if not isinstance(diagnostics, list) or len(diagnostics) != 0: + raise AssertionError(f"fixed overflow literal still reports diagnostics: {publish}") client.notify("textDocument/didClose", {"textDocument": {"uri": uri}}) client.wait_notification("textDocument/publishDiagnostics") @@ -455,6 +467,17 @@ def gate2(exe: str) -> int: items = pulled.get("items", []) if isinstance(pulled, dict) else [] if len(items) != 1: raise AssertionError(f"pull diagnostics returned {len(items)} items: {pulled}") + pull_client.notify( + "textDocument/didChange", + {"textDocument": {"uri": uri, "version": 5}, + "contentChanges": [{"text": fixed_overflow}]}, + ) + pulled = pull_client.request( + "textDocument/diagnostic", {"textDocument": {"uri": uri}}, timeout=60.0 + ).get("result") + items = pulled.get("items", []) if isinstance(pulled, dict) else [] + if len(items) != 0: + raise AssertionError(f"pull diagnostics kept the stale overflow: {pulled}") pull_client.request("shutdown") pull_client.close()