-
Notifications
You must be signed in to change notification settings - Fork 20
Render parens on zero arity fun definitions #51
Comments
I'll start work on this one. |
This looks like it will be fairly straightforward (famous last words). However I've run into a problem. The semantic tests in For example, changing the macro in defmacro infix_ops do
@infix_ops
end to: defmacro infix_ops() do
@infix_ops
end produces this error:
I'll dig into this, but wanted to post this in case you knew of an easy fix. |
The AST produced by a zero arity function definition without parentheses: quote do
def one do
1
end
end {:def, [context: Elixir, import: Kernel],
[{:one, [context: Elixir], Elixir}, [do: 1]]} differs more than I expected from the same function definition with parentheses: quote do
def one() do
1
end
end {:def, [context: Elixir, import: Kernel],
[{:one, [context: Elixir], []}, [do: 1]]} The semantic check is getting tripped up by this difference. |
'def' is just a macro invocation, and the change is from going from a 'binding' ast to a 'call' ast, which is definitely a big change. Internally the 'def' is a macro (as might other things be too) that can accept both (design fault in my opinion...). |
Thanks @OvermindDL1, that's very helpful. |
https://github.com/lexmag/elixir-style-guide#fun-parens
The text was updated successfully, but these errors were encountered: