Suggest `thin` when a `def(...)` closure trait is used as a type
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- compilers
Direzione di ricerca
Start by running the Dict[String, def(mut Parser, String) raises -> Int] repro and the thin variant to compare the two diagnostics. The current error mentions 'Movable' and AnyTrait[def(...)], so find where the compiler builds the parameter-mismatch message for a closure trait used as a type. Done when the message says 'closure trait', suggests adding thin after the argument list, and includes a fix-it that the LSP can apply.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
When a def(...) function type without thin appears where a type is expected, the compiler reports a parameter mismatch against AnyTrait[def(...)]. The message is accurate, but it doesn't explain the cause. It doesn't say that def(...) without thin is a closure trait and not a type, or that adding thin makes it a function pointer type.
Repro
@fieldwise_init
struct Parser(Movable):
var pos: Int
def parse_leaf(mut p: Parser, s: String) raises -> Int:
return 0
def main() raises:
var table = Dict[String, def(mut Parser, String) raises -> Int]()
table["leaf"] = parse_leaf
Current output
error: 'Dict' parameter 'V' has 'Movable' type, but value has type 'AnyTrait[def(mut Parser, String) raises -> Int]'
var table = Dict[String, def(mut Parser, String) raises -> Int]()
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
With def(mut Parser, String) thin raises -> Int, the repro compiles and runs.
It would also be nice if the message said "closure trait", not show AnyTrait[...]. It could also come with a fix-it that inserts thin after the argument list, so the LSP and other tools can apply it.Suggest thin when a def(...) closure trait is used as a type
- Lingua principale
- Mojo
- Stelle
- 30.2k
- Fork
- 3.2k
- Merge medio
- 6g 20h
- PR unite (30g)
- 25
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di modular/modular
-
bug_feature_triaged Team: Mojo Libraries
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
bug bug_feature_triaged documentation mojo
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
I maintainer di solito rispondono entro 2 giorni
-
`Counter.lt()` and `Counter.gt()` disagree with `__eq__`, and `a.lt(a)` can be `True`Forse già presa @YidaWeng l’ha presa 2 giorni fa. Apertabug_feature_triaged Team: Mojo Libraries
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
modular/modular#7696 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
[BUG] `Counter` `-=`, `+=` and `&=` leave keys behind when they remove many keysForse già presa @Tharun-Kumar-McW l’ha presa 5 giorni fa. Apertabug bug_feature_triaged mojo-stdlib Team: Mojo Libraries
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
modular/modular#7658 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
[BUG] exp(NaN) returns infApertabug bug_feature_triaged mojo Team: Mojo Libraries
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
modular/modular#7646 · 3 commenti ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di modular/modular
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
sagemathinc/sagebrush#1683 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
baseballyama/rsvelte#5235 ·
I maintainer di solito rispondono entro 1 giorno
-
lang-core: member access on a component instance reads its internal fields instead of giving nullApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
midspiral/LemmaScript#355 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno