Parser: many accepts input that ends inside an element
@GuillaumedeVolpiano đang làm issue này rồi.
Từ ngày 20/11/2026.
- #3273 của @GuillaumedeVolpiano — đang mở
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 52/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- backend
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Haskell
- Star
- 926
- Fork
- 71
- Merge trung bình
- 6 giờ 49 phút
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của composewell/streamly
-
takeInterval yields nothing, dropInterval drops nothingCó thể đã có người làm @GuillaumedeVolpiano đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
composewell/streamly#3271 ·
-
aspect:api
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 48/100
composewell/streamly#3206 ·
-
Rooted, unrooted path semanticsĐang mởapi:breaking aspect:api aspect:filesystem
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 35/100
composewell/streamly#3203 ·
-
type:performance
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 32/100
composewell/streamly#3200 · 2 bình luận ·
-
type:performance
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
composewell/streamly#3187 ·
Tất cả issue của composewell/streamly
Issue tương tự
-
bug desktop
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
simplex-chat/simplex-chat#8291 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG]: C# programs with top-level statements fail to compileCó thể đã có người làm @AsyncNigam đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
compiler-explorer/compiler-explorer#9625 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs triage type: enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 3 ngày
-
reflex-0.10Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
commercialhaskell/stackage#8180 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
OpenZeppelin/canton-contracts#140 ·
Maintainer thường phản hồi trong vòng 1 ngày