Behavior of HasType and HasInterface is counter-intuitive
まだ誰も着手していません。
評価
調査の方向性
markers/markers.go から始め、特に If とその UnwrapOnce の使用を確認してから、multi-errors に対する HasType と HasInterface のトラバーサル動作を Is および As と比較します。Sourcegraph PR 62992 における property-based testing のコンテキストを確認します。トラバーサルの違いを解決または文書化し、選択した動作に対するカバレッジを追加すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Go
- スター
- 2.5k
- フォーク
- 75
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
cockroachdb/errors のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
cockroachdb/errors#162 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
cockroachdb/errors#156 · リアクション 20 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
cockroachdb/errors#155 · コメント 1 件 · リアクション 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
cockroachdb/errors#146 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
cockroachdb/errors#138 · コメント 4 件 · リアクション 2 件 ·
cockroachdb/errors の issue をすべて見る
似ている issue
-
area/dev-productivity area/disaster-recovery area/ipcei kind/enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
kind/bug status/0-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
🤔 refinement needed
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
equinor/radix-operator#1979 ·