We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Erlang/OTP 26 [erts-14.2.5.4] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]
Elixir 1.18.1 (compiled with Erlang/OTP 26)
any
This code (where | represents the cursor)
|
defmodule MyModule do def my_fun(a, b) do case a do ^b -> b %{b: ^b} = |a -> b end end end
The cursor AST element lands on the wrong side of the second -> operator and the first one is transformed into a block as if the code was
->
defmodule MyModule do def my_fun(a, b) do case a do ^b -> b %{b: ^b} = __cursor__() end end end
Code.Fragment.container_cursor_to_quoted("defmodule MyModule do\n def my_fun(a, b) do\n case a do\n ^b -> b\n %{b: ^b} = ", trailing_fragment: "a ->b\n end\n end\nend") {:ok, {:defmodule, [line: 1], [ {:__aliases__, [line: 1], [:MyModule]}, [ do: {:def, [line: 2], [ {:my_fun, [line: 2], [{:a, [line: 2], nil}, {:b, [line: 2], nil}]}, [ do: {:case, [line: 3], [ {:a, [line: 3], nil}, [ do: [ {:->, [line: 4], [ [{:^, [line: 4], [{:b, [line: 4], nil}]}], {:__block__, [], [ {:b, [line: 4], nil}, {:=, [line: 5], [ {:%{}, [line: 5], [b: {:^, [line: 5], [{:b, [line: 5], nil}]}]}, {:__cursor__, [line: 5], []} ]} ]} ]} ] ] ]} ] ]} ] ]}}
trailing_fragment option does not seem to have any effect
trailing_fragment
Code.Fragment.container_cursor_to_quoted("defmodule MyModule do\n def my_fun(a, b) do\n case a do\n ^b -> b\n %{b: ^b} = ") {:ok, {:defmodule, [line: 1], [ {:__aliases__, [line: 1], [:MyModule]}, [ do: {:def, [line: 2], [ {:my_fun, [line: 2], [{:a, [line: 2], nil}, {:b, [line: 2], nil}]}, [ do: {:case, [line: 3], [ {:a, [line: 3], nil}, [ do: [ {:->, [line: 4], [ [{:^, [line: 4], [{:b, [line: 4], nil}]}], {:__block__, [], [ {:b, [line: 4], nil}, {:=, [line: 5], [ {:%{}, [line: 5], [b: {:^, [line: 5], [{:b, [line: 5], nil}]}]}, {:__cursor__, [line: 5], []} ]} ]} ]} ] ] ]} ] ]} ] ]}}
I'm aware that this case in ambiguous but given the trailing fragment container_cursor_to_quoted should be able to resolve it in favour of correct AST
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Elixir and Erlang/OTP versions
Erlang/OTP 26 [erts-14.2.5.4] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]
Elixir 1.18.1 (compiled with Erlang/OTP 26)
Operating system
any
Current behavior
This code (where
|
represents the cursor)The cursor AST element lands on the wrong side of the second
->
operator and the first one is transformed into a block as if the code wastrailing_fragment
option does not seem to have any effectExpected behavior
I'm aware that this case in ambiguous but given the trailing fragment container_cursor_to_quoted should be able to resolve it in favour of correct AST
The text was updated successfully, but these errors were encountered: