Skip to content
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

Box<impl Trait> peg 0.8.1 regression #319

Closed
fmorency opened this issue Oct 17, 2022 · 1 comment
Closed

Box<impl Trait> peg 0.8.1 regression #319

fmorency opened this issue Oct 17, 2022 · 1 comment

Comments

@fmorency
Copy link

Compilation of a peg::parser containing a function returning a Box<impl Trait> will fail with peg 0.8.1 but succeed with peg 0.8.0.

E.g.

peg::parser!{
        grammar list_parser() for str {
            rule number() -> u64
                = n:$(['0'..='9']+) {? n.parse().or(Err("u64")) }

            pub rule list() -> Box<impl FooTrait>
                = n:(number()) { Box::new(FooStruct { val: n }) }
        }
    }

MRE: https://github.com/fmorency/peg-box-impl

@kevinmehall
Copy link
Owner

Oops, this is from adding a type annotation to help type inference (#317), but impl Trait can't be named except in a return type position. We'll have to figure out how to fix type inference in that case without explicitly naming the type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants