tree-sitter-elixir
tree-sitter-elixir copied to clipboard
Incorrect function parameter highlighting for bitstring pattern matching
Example:

Parsed tree for reference:
(program [0, 0] - [3, 0]
(call [0, 0] - [2, 3]
name: (identifier [0, 0] - [0, 3])
(call [0, 4] - [0, 48]
name: (identifier [0, 4] - [0, 8])
(arguments [0, 8] - [0, 48]
(binary [0, 9] - [0, 47]
(binary_op [0, 11] - [0, 31]
left: (identifier [0, 11] - [0, 15])
right: (binary_op [0, 17] - [0, 31]
left: (identifier [0, 17] - [0, 23])
right: (call [0, 24] - [0, 31]
name: (identifier [0, 24] - [0, 28])
(arguments [0, 28] - [0, 31]
(integer [0, 29] - [0, 30])))))
(binary_op [0, 33] - [0, 45]
left: (identifier [0, 33] - [0, 37])
right: (identifier [0, 39] - [0, 45])))))
(do_block [0, 49] - [2, 3]
(identifier [1, 2] - [1, 6]))))
To have a proper fix I think we have to parse bitstring options differently. Currently, we are treating it as an arithmetic expression
is the AST from master? I got the following from wasm which seems similar to the elixir AST. Agree, highlighting needs to be fixed though.
program [0, 0] - [3, 0])
call [0, 0] - [2, 3])
name: identifier [0, 0] - [0, 3])
call [0, 4] - [0, 48])
name: identifier [0, 4] - [0, 8])
arguments [0, 8] - [0, 48])
binary [0, 9] - [0, 47])
binary_op [0, 11] - [0, 31])
left: identifier [0, 11] - [0, 15])
right: binary_op [0, 17] - [0, 31])
left: identifier [0, 17] - [0, 23])
right: call [0, 24] - [0, 31])
name: identifier [0, 24] - [0, 28])
arguments [0, 28] - [0, 31])
integer [0, 29] - [0, 30])
binary_op [0, 33] - [0, 45])
left: identifier [0, 33] - [0, 37])
right: identifier [0, 39] - [0, 45])
do_block [0, 49] - [2, 3])
identifier [1, 2] - [1, 6])
iex(1)> quote do
...(1)> <<head::binary-size(2), rest::binary>> = y
...(1)> end
{:=, [],
[
{:<<>>, [],
[
{:"::", [],
[
{:head, [], Elixir},
{:-, [context: Elixir, import: Kernel],
[{:binary, [], Elixir}, {:size, [], [2]}]}
]},
{:"::", [], [{:rest, [], Elixir}, {:binary, [], Elixir}]}
]},
{:y, [], Elixir}
]}
My bad, previous AST was for different code. Updated now.
seems similar to the elixir AST
Ack