chumsky
chumsky copied to clipboard
`just(range)` passes the range as output instead of the matched value (1.0.7 alpha)
Repro:
use chumsky::prelude::*;
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum Instr { Name(char) }
fn parser<'a>() -> impl Parser<'a, &'a str, Vec<Instr>, extra::Err<Rich<'a, char>>> {
let name = just('a'..='z').map(Instr::Name);
name.padded().repeated().collect()
}
This does not compile due to:
error[E0631]: type mismatch in function arguments
--> src/lib.rs:9:36
|
5 | Name(char),
| ---- found signature defined here
...
9 | let name = just('a'..='z').map(Instr::Name);
| --- ^^^^^^^^^^^ expected due to this
| |
| required by a bound introduced by this call
|
= note: expected function signature `fn(RangeInclusive<char>) -> _`
found function signature `fn(char) -> _`
note: required by a bound in `chumsky::Parser::map`
--> /Users/orvar/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chumsky-1.0.0-alpha.7/src/lib.rs:519:18
|
519 | fn map<U, F: Fn(O) -> U>(self, f: F) -> Map<Self, O, F>
| ^^^^^^^^^^ required by this bound in `Parser::map`
help: consider wrapping the function in a closure
|
9 | let name = just('a'..='z').map(|arg0: RangeInclusive<char>| Instr::Name(/* char */));
| ++++++++++++++++++++++++++++ ++++++++++++