Skip to content

Commit a4ba66c

Browse files
committed
consuemWith: propagate consumed flag it was set
The Parsing design implies that if input was consumed, it must propagate further unless `try` is used to reset that. Fixes: #236
1 parent c38e6ea commit a4ba66c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Parsing/String.purs

+2-2
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,12 @@ consumeWith
282282
. (String -> Either String { value :: a, consumed :: String, remainder :: String })
283283
-> ParserT String m a
284284
consumeWith f = ParserT
285-
( mkFn5 \state1@(ParseState input pos _) _ _ throw done ->
285+
( mkFn5 \state1@(ParseState input pos oldConsumed) _ _ throw done ->
286286
case f input of
287287
Left err ->
288288
runFn2 throw state1 (ParseError err pos)
289289
Right { value, consumed, remainder } ->
290-
runFn2 done (ParseState remainder (updatePosString pos consumed remainder) (not (String.null consumed))) value
290+
runFn2 done (ParseState remainder (updatePosString pos consumed remainder) (oldConsumed || not (String.null consumed))) value
291291
)
292292

293293
-- | Combinator which finds the first position in the input `String` where the

0 commit comments

Comments
 (0)