dotnet / dotnet/fsharp

Compiler silently drops diagnostics with unknown range

未關閉
#14,653 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
Area-Diagnostics Bug Impact-Medium
主要語言
F#
星號
4.3k
分支
876
平均合併
4 天 22 小時
30 天內合併 PR
144

描述

If a diagnostic would be emitted but it has an unknown range, we sometimes drop it on the floor. This seems non-ideal.

**Repro steps**

See the F# compiler built from https://github.com/Smaug123/fsharp-1/commit/76ea258b45dbea90e2ea28069d76065f1de6c354 . The test "Three types refined to obj are all warned" in ObjInference.fs incorrectly fails because it reports that no diagnostics were emitted. In fact diagnostics were requested, but were suppressed just before reporting: place a breakpoint at FSharpDiagnostic.fs line 203 in `ReportDiagnostic` to observe our decision not to emit the errors that arose on [line 185 of TypeRelations.fs](https://github.com/Smaug123/fsharp-1/commit/76ea258b45dbea90e2ea28069d76065f1de6c354#diff-99e9d8b56b1879061a50d28265e437772930bfe5c5ba465ede161a735e19adafR185) because their associated ranges were all the unknown range.

**Expected behavior**

The test "Three types refined to obj are all warned" should pass, because it notes that three diagnostics were emitted.

**Actual behavior**

No diagnostics were emitted, so the test fails.

**Known workarounds**

We could possibly just make sure that every diagnostic always has a meaningful range (which seems invasive and difficult), or we could run in "all errors" mode (but I don't understand the implications of that).

貢獻指南

開啟貢獻指南

研究方向

Start with the "Three types refined to obj are all warned" test in ObjInference.fs and reproduce its missing diagnostics. Inspect ReportDiagnostic at FSharpDiagnostic.fs line 203 and the diagnostic-producing path at TypeRelations.fs line 185, then determine how unknown ranges should be handled. Done means the test passes and confirms that the three diagnostics are emitted.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
fsharp
領域
compilers
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。