Skip to content

Newlines handled differently compared to old parser #316

@mortenpi

Description

@mortenpi

I am not really sure if this is a bug, or maybe it's a bug in the original parser, but it looks like newlines are handled differently in JuliaSyntax.

This broke Documenter's tests (for some reason it's blacklisted in PkgEval), since we do some exact string checks there for parsed sub-expressions, so the cursor value changes threw those tests off. It's not a problem to handle this with version guards (JuliaDocs/Documenter.jl#2146), but it would be good to know whether this change might change back at some point or not.

Here are some Meta.parse calls in 1.9 vs today's master:

[email protected]> Meta.parse("x += 3\nγγγ_γγγ\nγγγ\n\n", 22; raise=true)
(:γγγ, 29)

[email protected]> Meta.parse("x += 3\nγγγ_γγγ\nγγγ\n\n", 22; raise=true)
(:γγγ, 30)
[email protected]> Meta.parse("x = Int[]\r\n\r\npush!(x, 1)\r\n\n", 14)
(:(push!(x, 1)), 27)

[email protected]> Meta.parse("x = Int[]\r\n\r\npush!(x, 1)\r\n\n", 14)
(:(push!(x, 1)), 28)
[email protected]> Meta.parse("x = Int[]\n\npush!(x, 1)\n\n", 12)
(:(push!(x, 1)), 24)

[email protected]> Meta.parse("x = Int[]\n\npush!(x, 1)\n\n", 12)
(:(push!(x, 1)), 25)
[email protected]> Meta.parse("1 + 1\n2 + 2\n\n", 7)
(:(2 + 2), 13)

[email protected]> Meta.parse("1 + 1\n2 + 2\n\n", 7)
(:(2 + 2), 14)
[email protected]> Meta.parse("1 + 1\n\n\n", 1)
(:(1 + 1), 7)

[email protected]> Meta.parse("1 + 1\n\n\n", 1)
(:(1 + 1), 9)

Slightly more interesting case with a comment line:

[email protected]> Meta.parse("1 + 1\n# comment\n\n", 1)
(:(1 + 1), 7)

[email protected]> Meta.parse("1 + 1\n# comment\n\n", 1)
(:(1 + 1), 18)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions