-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why does label
act only on the first set of hints?
#482
Comments
This is not exactly the same situation as in your example, but I recently also encountered a case where Running {-# LANGUAGE OverloadedStrings #-}
import Data.Void (Void)
import Text.Megaparsec (Parsec, errorBundlePretty, label, parse)
import Text.Megaparsec.Char (space)
main :: IO ()
main = do
let s :: Parsec Void String ()
s = label "spaces" space
let p :: Parsec Void String String
p = label "<p>" ("A" <* s)
case parse (p *> p) mempty "A B" of
Left e -> putStr (errorBundlePretty e)
Right _ -> error "Unexpected `Right _`." against 2a46074 prints the built-in label of
Not knowing how labels are implemented in megaparsec/Text/Megaparsec/Class.hs Lines 57 to 60 in 2a46074
Since |
Hey @j-mie6, that's a good catch. I think there is really no reason why we shouldn't modify both |
When you have a parser like:
If
r
fails, the hints fromp
andq
are usually reported as possible expected tokens. However, in this casep
s hints are relabelled toname
, butq
s are not. This is clearly the expected behaviour from the library as implemented explicitly byrefreshLastHints
. What I'm wondering, however, is what the rationale was behind this design choice?The text was updated successfully, but these errors were encountered: