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()