This addresses the second part of jeremyjh/dialyxir#346. The issue there is contract type vars used in when clauses are formatted like they are an atom literal.
e.g.
@spec do_stuff(avar) :: res when avar: term(), res: binary()
would get printed as
@spec do_stuff(:avar) :: :res when avar: term, res: binary
My fix is not beautiful, but I think its straightforward and low risk. We just make a list of all the names used in the when clause, and strip those names of a leading :.
I didn't pursue it too deeply but I think a possible alternative would be treat what gets lexed as atom_part as a name - in contracts atom literals come single quoted and lex as :atom_full. I really only looked at the contracts, you may already know this is is a non-starter.
But for example the spec
@spec ok(km, :fnord) :: km when km: term
comes to us Erlangified in the contract arg as
(km, s, 'fnord') -> km when km :: term(), s :: atom()
Everything coming out of the lex() as :atom_part are non-atom-literals that we'll have to strip of ":" downstream.
This addresses the second part of jeremyjh/dialyxir#346. The issue there is contract type vars used in when clauses are formatted like they are an atom literal.
e.g.
would get printed as
My fix is not beautiful, but I think its straightforward and low risk. We just make a list of all the names used in the when clause, and strip those names of a leading
:
.I didn't pursue it too deeply but I think a possible alternative would be treat what gets lexed as
atom_part
as a name - in contracts atom literals come single quoted and lex as:atom_full
. I really only looked at the contracts, you may already know this is is a non-starter.But for example the spec
comes to us Erlangified in the contract arg as
(km, s, 'fnord') -> km when km :: term(), s :: atom()
Everything coming out of the
lex()
as:atom_part
are non-atom-literals that we'll have to strip of ":" downstream.