Treat span-like types with a unit of measure as byref-like
Mantenedores costumam responder em até 2 dias
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 40/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Domínio
- compilers
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- F#
- Estrelas
- 4.3k
- Forks
- 884
- Merge médio
- 2d 11h
- PRs com merge (30d)
- 73
Preparar o ambiente
Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de dotnet/fsharp
-
Needs-Triage
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 95/100
Mantenedores costumam responder em até 2 dias
-
Semantic classification cache for opened documents is never populated (written to the unopened-documents cache)Talvez já em andamento @xperiandri assumiu há 69 dias. AbertaNeeds-Triage
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
Mantenedores costumam responder em até 2 dias
-
Needs-Triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
dotnet/fsharp#20265 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
Bug Needs-Triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 2 dias
-
Needs-Triage
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 45/100
Mantenedores costumam responder em até 2 dias
Todas as issues de dotnet/fsharp
Issues semelhantes
-
from-agent
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
-
code quality wasm backend
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 84/100
nanyx-lang/nanyx#930 ·
Mantenedores costumam responder em até 1 dia
-
[mlir][math] math-expand-ops computes math.ctlz wrongly for widths that are not a power of twoAbertamlir
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
llvm/llvm-project#241891 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
arrays bug intrinsic llvm medium priority wrong result
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
Mantenedores costumam responder em até 1 dia
-
`lower_throw!` treats any function whose name contains `jl_error` etc. as a throw (kernel becomes a trap / segfault)Talvez já em andamento @sasmith-14 assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
JuliaGPU/GPUCompiler.jl#1088 ·
Mantenedores costumam responder em até 1 dia