Skip to content

Parser metadata not attached on blocks consistently #14931

@lukaszsamson

Description

@lukaszsamson

Elixir and Erlang/OTP versions

Erlang/OTP 27 [erts-15.2.7.3] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]

Elixir 1.19.3 (compiled with Erlang/OTP 27)

Operating system

any

Current behavior

I noticed this inconsistency: line and column meta is attached to block only in some cases

iex(1)> Code.string_to_quoted!("", columns: true)
{:__block__, [], []}
iex(2)> Code.string_to_quoted!(" ", columns: true)
{:__block__, [], []}
iex(3)> Code.string_to_quoted!("\n", columns: true)
{:__block__, [line: 1, column: 1], []}
iex(4)> Code.string_to_quoted!("#", columns: true)
{:__block__, [], []}
iex(5)> Code.string_to_quoted!("#\n", columns: true)
{:__block__, [line: 1, column: 1], []}
iex(6)> Code.string_to_quoted!(";", columns: true)
{:__block__, [line: 1, column: 1], []}
iex(11)> Code.string_to_quoted!("a\nb", columns: true)
{:__block__, [],
 [{:a, [line: 1, column: 1], nil}, {:b, [line: 2, column: 1], nil}]}

Expected behavior

Consistent line and column meta when block represents a real range in code

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