Behavior of HasType and HasInterface is counter-intuitive
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia in markers/markers.go, in particolare con If e il suo utilizzo di UnwrapOnce, quindi confronta il comportamento di attraversamento di HasType e HasInterface con quello di Is e As per i multi-errori. Esamina il contesto dei test basati sulle proprietà in Sourcegraph PR 62992. Il lavoro è completato quando la differenza nell’attraversamento è stata risolta o documentata e sono stati aggiunti test per il comportamento scelto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Both of these functions call If which does a traversal of the causal chain, it does not traverse the full tree. Specifically, If internally calls UnwrapOnce and doesn't handle the multi-error case, whereas functions like Is and As separately handle the multi-error case.
This leads to counter-intuitive behavior; you can have a value x of type T, and errors.Is(err, x) may be true, but errors.HasType(err, T{}) may fail.
I noticed this behavior while trying to add property-based tests to better understand the behavior of HasType here. https://github.com/sourcegraph/sourcegraph/pull/62992
It would be valuable to either:
- Change the implementation of
Ifto traverse the full tree - OR Add a separate function which does a tree traversal (not just the "causal chain") and use that from
HasTypeandHasInterface - OR Add a cautionary warning to
HasTypeandHasInterface's docs which describe the behavior in the presence of multi-errors.
- Lingua principale
- Go
- Stelle
- 2.5k
- Fork
- 75
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
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 cockroachdb/errors
-
Errors returned from Join are incompatible with errors returned the standard lib's errors.Join Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
cockroachdb/errors#162 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
cockroachdb/errors#156 · 20 reazioni ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
cockroachdb/errors#155 · 1 commento · 1 reazione ·
-
move subpackages to internal Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
cockroachdb/errors#146 ·
-
Gogoprotobuf replacement Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
cockroachdb/errors#138 · 4 commenti · 2 reazioni ·
Tutte le issue di cockroachdb/errors
Issue simili
-
textual definition
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
geneontology/go-ontology#32653 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
-
needs design
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Priority/High ready-for-agent Severity/Major Type/Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100