Skip to content

-spec Loses Syntax Highlighting After Named Anonymous Function #316

@EarthCitizen

Description

@EarthCitizen

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions