Fun call in argument list causes incorrect indentation for later arguments
fishcakez opened this issue · 3 comments
fishcakez commented
Example:
eval(Fun, Arg) ->
handle_result(Fun(Arg),
true).hcs42 commented
Thanks, I can reproduce it, I will investigate it.
fishcakez commented
Also when used in a case:
eval(Fun, Arg) ->
case handle_result(Fun(Arg)) of
true ->
true
end.hcs42 commented
This is indeed a bug in indent.erl.
The bug is caused by the fact that I use == to check whether the current token is fun – but it turns out, if the 'ignorecase' option is turned on, == is case insensitive, i.e. "fun" == "Fun" is true, so indent.erl believes that Fun(Arg) is the beginning of an anonymous function definition. The solution is to use the ==# operator which is always case sensitive.
We have a similar problem with the searchpair function – here the solution is to add \C to the pattern (which means "be case sensitive").