Parser: many accepts input that ends inside an element
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 52/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 領域
- backend
調査の方向性
Start with the reproduction using P.many, line, and P.eof, and compare the reported results for parse and parsePos. The issue links #1491 as possibly related; read it for context on parser alternatives and backtracking. Done means malformed final elements fail consistently, with behavior verified against all four inputs in the reproduction.
索引モデルが issue の本文から書いたものです。
説明
Package: streamly-core 0.3.3
GHC: 9.12.4
Reproduction
import Data.Functor.Identity
import qualified Streamly.Data.Fold as Fold
import qualified Streamly.Data.Parser as P
import qualified Streamly.Data.Stream as S
-- "many" of ('n', then one or more non-':' characters, then ':'), then eof.
line :: P.Parser Char Identity String
line = P.satisfy (== 'n') *> P.takeWhile1 (/= ':') Fold.toList <* P.satisfy (== ':')
p :: P.Parser Char Identity [String]
p = P.many line Fold.toList <* P.eof
main :: IO ()
main = do
let run s = (runIdentity (S.parse p (S.fromList s)), runIdentity (S.parsePos p (S.fromList s)))
print (run "nab:ncd:")
print (run "nab:ncd")
print (run "nab:x")
print (run "ncd")
| Input | Expected | Actual |
|---|---|---|
nab:ncd: |
Right ["ab","cd"] |
Right ["ab","cd"] |
nab:ncd |
Left: ncd is not a line |
Right ["ab"] |
nab:x |
Left: x is not a line |
Left (ParseError "eof: not at end of input") |
ncd |
Left |
Right [] |
What happens
When the input ends while many is in the middle of an element, the element
fails, many stops with the elements it had, and the input the failed element
had consumed is not given back: eof then succeeds. When the element fails on
a character instead (nab:x), the input is given back and eof fails as
expected.
So a malformed last element goes unnoticed whenever the input stops inside it.
I expected many to backtrack to the start of the failed element in both
cases, as it does for nab:x.
The same happens with parsePos.
Possibly related, though about the alternative of parsers and closed: #1491.
- 主要言語
- Haskell
- スター
- 926
- フォーク
- 71
- 平均マージ
- 6時間 49分
- マージ済み PR(30日)
- 3
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
composewell/streamly のほかの issue
-
takeInterval yields nothing, dropInterval drops nothing対応中かも @GuillaumedeVolpiano が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
composewell/streamly#3271 ·
-
aspect:api
難易度 4/5 1〜2日 初心者へのやさしさ 48/100
composewell/streamly#3206 ·
-
api:breaking aspect:api aspect:filesystem
難易度 4/5 1〜2日 初心者へのやさしさ 35/100
composewell/streamly#3203 ·
-
type:performance
難易度 4/5 3〜5日 初心者へのやさしさ 32/100
composewell/streamly#3200 · コメント 2 件 ·
-
type:performance
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
composewell/streamly#3187 ·
composewell/streamly の issue をすべて見る
似ている issue
-
bug desktop
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
simplex-chat/simplex-chat#8291 ·
メンテナーはふだん 1 日以内に返信
-
[BUG]: C# programs with top-level statements fail to compile対応中かも @AsyncNigam が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
compiler-explorer/compiler-explorer#9625 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
needs triage type: enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 3 日以内に返信
-
reflex-0.10オープン
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
commercialhaskell/stackage#8180 ·
メンテナーはふだん 1 日以内に返信
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
OpenZeppelin/canton-contracts#140 ·
メンテナーはふだん 1 日以内に返信