I understand the reason that parenthesis can't be added to nullary local functions and that if you walk the AST without keeping any state the formatter can't discern a local type from a local nullary function call.
However, when the formatter does keep some state while walking the tree it should be possible for the formatter to understand which AST nodes are part of a typespec? Given the following typespec: @type my_type :: my_other_type The corresponding AST should be something like: {:@, [line: 1], [ {:type, [line: 1], [ {:::, [line: 1], [{:my_type, [line: 1], nil}, {:my_other_type, [line: 1], nil}]} ]} ]} So the formatter encounters an attribute node {:@, ...}, updates it state that if the next node starts with :type, we are at the start of a typespec, etc. Is interpreting the AST like this considered too fragile/brittle, or am I missing something else? Best, Vincent Op maandag 5 februari 2018 15:10:05 UTC+1 schreef Eric Meadows-Jönsson: > > Typespecs are following the same rules as all other code because the > formatter only sees AST and can't discern typespecs from executed code. > > We can't add parenthesis to nullary local function calls because they have > the same AST representation as variables so adding parenthesis would break > code. > > > -- > Eric Meadows-Jönsson > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/f1efdaf8-c8b8-4197-b1f2-622bd5b2190e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.