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

Parsing expression a.0.1 doesn't have the right spans #1433

Closed
tjhance opened this issue Mar 30, 2023 · 0 comments · Fixed by #1436
Closed

Parsing expression a.0.1 doesn't have the right spans #1433

tjhance opened this issue Mar 30, 2023 · 0 comments · Fixed by #1436

Comments

@tjhance
Copy link

tjhance commented Mar 30, 2023

When syn parses an expression like a.0.1, the resulting Member objects don't have spans I expect.

Expr::Field {
    attrs: [],
    base: Expr::Field {
        attrs: [],
        base: Expr::Path {
            attrs: [],
            qself: None,
            path: Path {
                leading_colon: None,
                segments: [
                    PathSegment {
                        ident: Ident {
                            ident: "a",
                            span: #0 bytes(95..96),
                        },
                        arguments: PathArguments::None,
                    },
                ],
            },
        },
        dot_token: Dot,
        member: Member::Unnamed(
            Index {
                index: 0,
                span: #5 bytes(0..102),  ////////////////// this span isn't what I expect
            },
        ),
    },
    dot_token: Dot,
    member: Member::Unnamed(
        Index {
            index: 1,
            span: #5 bytes(0..102), ////////////////// this span isn't what I expect
        },
    ),
}

By contrast, x.0 is parsed with the spans that I'd expect:

Expr::Field {
    attrs: [],
    base: Expr::Path {
        attrs: [],
        qself: None,
        path: Path {
            leading_colon: None,
            segments: [
                PathSegment {
                    ident: Ident {
                        ident: "a",
                        span: #0 bytes(95..96),
                    },
                    arguments: PathArguments::None,
                },
            ],
        },
    },
    dot_token: Dot,
    member: Member::Unnamed(
        Index {
            index: 0,
            span: #0 bytes(97..98),     ////////////////// this span is what I expect
        },
    ),
}
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

Successfully merging a pull request may close this issue.

1 participant