-
Notifications
You must be signed in to change notification settings - Fork 46
-spec Loses Syntax Highlighting After Named Anonymous Function #316
Copy link
Copy link
Open
Description
In the below example, in VSCode, after the definition of cycle(), the rest of the -spec definitions in the file lose syntax highlighting. In my theme, the -spec above cycle(), and all before, are purple, whereas, the -spec above integer_between(), and all the rest in the file, are white.
-spec cycle(nonempty_list(gen(_))) -> gen(_).
cycle(AllGens = [_, _ | _]) ->
StateKey = {gens, cycle, get_seq()},
InitState = fun () -> put(StateKey, 1) end,
GetNextIndex = fun NextIndex () ->
case get(StateKey) of
N when undefined == N orelse N > length(AllGens) -> InitState(), NextIndex();
N -> put(StateKey, N + 1), N
end
end,
{gen, calc, fun () -> lists:nth(GetNextIndex(), AllGens) end}.
-spec integer_between(integer(), integer()) -> gen(integer()).
integer_between(MinBound, MaxBound) when MinBound < MaxBound ->
MaxFromZero = MaxBound - MinBound,
OffSet = MaxBound - MaxFromZero,
{val, calc, fun() -> trunc(abs(uniform()) * (MaxFromZero + 1)) + OffSet end}.If I remove the name NextIndex from the anonymous function, the -spec highlighting returns.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels