Erlang syntax highlighting error (with potential fix!)

Anselm Eickhoff 6 years ago 0

In Erlang, fun is not only a keyword for lambdas, but can also be used in -spec macro directives.


-spec for_house_of(Type :: row|column|box,
  Pos :: integer(),
  AccStart :: X,
  Fun :: fun((Pos :: integer(), Acc::X) -> (Y))
) -> [Y].

This breaks syntax highlighting afterwards though (because Sublime text thinks we're in an anonymous function that has never been ended).

(multiline or single line -spec doesn't matter).

It can be fixed by ignoring the fun keyword if it follows two colons in this case:

Erlang.tmLanguage, line 699





This is only a hack though, because the parameter spec could also be unnamed:

-spec for_house_of(Type :: row|column|box,
  fun((integer(), X) -> (Y))
) -> [Y].