Column offsets in nested f-string expressions are wrong · Issue #114 · we-like-parsers/cpython · GitHub
Skip to content

Column offsets in nested f-string expressions are wrong #114

Description

@lysnikolaou

Parsing the following:

expr = """
a = 10
f'{a * f"-{x()}-"}'"""

produces the following AST (not complete):

...
op=Mult(),
right=JoinedStr(
    values=[
        Constant(
            value="-",
            lineno=1,
            col_offset=5,
            end_lineno=1,
            end_col_offset=15,
        ),
        FormattedValue(
            value=Call(
                func=Name(
                    id="x",
                    ctx=Load(),
                    lineno=1,
                    col_offset=9,
                    end_lineno=1,
                    end_col_offset=10,
                ),
                args=[],
                keywords=[],
                lineno=1,
                col_offset=9,
                end_lineno=1,
                end_col_offset=12,
            ),
            conversion=-1,
            lineno=1,
            col_offset=5,
            end_lineno=1,
            end_col_offset=15,
        ),
        Constant(
            value="-",
            lineno=1,
            col_offset=5,
            end_lineno=1,
            end_col_offset=15,
        ),
                            ],
lineno=3,
col_offset=7,
end_lineno=3,
end_col_offset=17,
...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

3.9.0b1Needs to be fixed/implemented until the 3.9.0b1 release

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions