Skip to content
New issue

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

lsp autocorrects incorrectly #758

Closed
waalge opened this issue Nov 2, 2023 · 4 comments
Closed

lsp autocorrects incorrectly #758

waalge opened this issue Nov 2, 2023 · 4 comments

Comments

@waalge
Copy link
Contributor

waalge commented Nov 2, 2023

What Git revision are you using?

$aiken --version
aiken v1.0.19-alpha+unknown

What operating system are you using, and which version?

nixos

Describe what the problem is?

lsp autocorrect on write to incorrect code.

Sample line:

  expect x == (y |> bytearray.take(3) )

Is being "corrected" to

  expect x == y |> bytearray.take(3)

which (see chat about fixity) is garbage.

What should be the expected behavior?

Preferably fixity was done sensibly (I dont know why we should do the same as elm - i don't see any benefit) .
Failing that, that this is not autoformatted incorrectly.


This was a problem before in early alpha, possibly pre-alpha, and the reason i didn't use formatting for a long time.

I will try bumping to v20 to see if it remains

@rvcas
Copy link
Member

rvcas commented Nov 2, 2023

I don't think it's fixed in 20. This is a long standing issue related to how groups get formatted. Thanks for reporting, we'll fix it

@rvcas
Copy link
Member

rvcas commented Nov 2, 2023

btw in regards to the sensible argument. it currently is sensible. it's not just cause elm does it. So does elixir, that's just how precedence is done on languages with pipes. look at this examples from the other issue

a + 2
|> add_one
|> add_one

what's the correct precedence here?

or for this

a == 2
|> foo
|> bar

It seems pretty clear to me that |> should have the lowest precedence otherwise you wouldn't be able to do something as basic as piping a binary operation expression into something.

@waalge
Copy link
Contributor Author

waalge commented Nov 3, 2023

Not all binary operators have the same precedence eg 2 + 3 == 5 is unambiguously true.

The precedence of pipe is moot. I don't write elixir or understand elixir docs. According to a cpp prop
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2672r0.html#operator-precedence
elm and elixir don't work the same. The placement of elm looks right
https://faq.elm-community.org/operators.html . Can't speak for elixir. Helpfully different languages use opposite scales of precedence.

I like (a + 2) |> add_one and a == b |> f

Its a choice. Personally I would choose pipe higher. Regardless, it would be helpful if precedence was explicitly documented.

@rvcas
Copy link
Member

rvcas commented Nov 28, 2023

this should have been fixed in #764 please let me know if the problem persists

@rvcas rvcas closed this as completed Nov 28, 2023
@rvcas rvcas moved this to ✅ Done in Project Tracking Mar 22, 2024
@rvcas rvcas moved this to 🚀 Released in Project Tracking May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🚀 Released
Development

No branches or pull requests

2 participants