Treat span-like types with a unit of measure as byref-like
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 40/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 領域
- compilers
調査の方向性
Start from isByrefLikeTyconRef and stripTyEqns in the compiler's type utilities, which the report says miss the representation of measure-annotated abbreviations. Run the repro with the TaggedSpan<kg> example and compare with the TaggedSpan<1> case, which already gives FS0406 and FS0412. Done means the kg version reports the same errors and existing byref-like tests still pass. The author already has a fix, so check with the maintainers before starting a parallel one.
索引モデルが issue の本文から書いたものです。
説明
A measure-annotated abbreviation of Span<int> is not treated as byref-like when its unit of measure is anything other than 1. The compiler then accepts code that captures such a value in a closure or uses its type as a type argument, and the program fails at run time.
open System
[<Measure>] type kg
[<MeasureAnnotatedAbbreviation>]
type TaggedSpan<[<Measure>] 'u> = Span<int>
let size (s: TaggedSpan<'u>) = 0
let capture (s: TaggedSpan<kg>) = let t = s in fun () -> size t
let instantiate (s: TaggedSpan<kg>) = id s
[<EntryPoint>]
let main args =
let s = Unchecked.defaultof<TaggedSpan<kg>>
if args.Length = 0 then capture s () else size (instantiate s)
Actual: this compiles with the .NET SDK 10.0.402 compiler and with main at fbc9be3. Compiled without optimization:
- With no arguments,
capturethrowsTypeLoadException: A ByRef or ByRef-like type cannot be used as the type for an instance field in a non-ByRef-like type. - With an argument,
instantiatethrowsVerificationException: Method Microsoft.FSharp.Core.Operators.Identity: type argument 'System.Span`1[System.Int32]' violates the constraint of type parameter 'T'.
Expected: the errors the compiler reports when kg is replaced by 1: FS0406 on the closure in capture, and FS0412 on id s and on Unchecked.defaultof.
isByrefLikeTyconRef does not look at the representation of a measure-annotated type, and stripTyEqns reduces such a type to its representation only when the measure is dimensionless, so TaggedSpan<kg> is not recognised as byref-like. I found this while reviewing #20856, whose tests define TaggedSpan. I have a fix ready.
[!NOTE]
Prepared with AI assistance (Anthropic Claude, OpenAI Codex); Peter reviewed it.
- 主要言語
- F#
- スター
- 4.3k
- フォーク
- 884
- 平均マージ
- 2日 11時間
- マージ済み PR(30日)
- 73
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dotnet/fsharp のほかの issue
-
Needs-Triage
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
メンテナーはふだん 2 日以内に返信
-
Semantic classification cache for opened documents is never populated (written to the unopened-documents cache)対応中かも @xperiandri が 69 日前に担当しました。 オープンNeeds-Triage
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 2 日以内に返信
-
Needs-Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
dotnet/fsharp#20265 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
Bug Needs-Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
Needs-Triage
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
メンテナーはふだん 2 日以内に返信
似ている issue
-
from-agent
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
code quality wasm backend
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
nanyx-lang/nanyx#930 ·
メンテナーはふだん 1 日以内に返信
-
mlir
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
llvm/llvm-project#241891 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
arrays bug intrinsic llvm medium priority wrong result
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
`lower_throw!` treats any function whose name contains `jl_error` etc. as a throw (kernel becomes a trap / segfault)対応中かも @sasmith-14 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
JuliaGPU/GPUCompiler.jl#1088 ·
メンテナーはふだん 1 日以内に返信