Closed jeremyjh closed 5 years ago
Merging #42 into master will increase coverage by
0.19%
. The diff coverage is100%
.
@@ Coverage Diff @@
## master #42 +/- ##
==========================================
+ Coverage 85.81% 86.01% +0.19%
==========================================
Files 1 1
Lines 141 143 +2
==========================================
+ Hits 121 123 +2
Misses 20 20
Impacted Files | Coverage Δ | |
---|---|---|
lib/erlex.ex | 86.01% <100%> (+0.19%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update f5b2a4d...5fba426. Read the comment docs.
Bump.
If you don't want the PR we should at least cherry-pick this bug fix: https://github.com/asummers/erlex/pull/42/files#diff-314c048f5422aeb5c6083de98d4b4404R540
Currently type variables with underscores in when clauses will throw an exception.
This seems reasonable! Totally missed this PR, sorry about that. I'll push out a release with these changes tonight.
@asummers just a reminder to please cut a hex release when you can; I'm waiting on it for another dialyxir rc
Done.
Follow-up to this discussion.
In Erlang and Elixir syntax, the names used in a spec
when
clause are variables - type variables. So in Erlang they must follow Erlang's variable syntax:In Elixir variables must begin with a lower case letter or underscore, and can contain upper/lower case letters, numbers and underscores.
So if we want Erlex pretty printed Erlang contracts to compile in Elixir, we need to transform legal Erlang type variable names to legal Elixir type variable names.
This PR helps us do that. It will lowercase the first character of an uppercase variable name used in when clauses. It also fixes a bug I introduced in the last PR that caused an exception on type variables including underscores, since those don't get lexed as a legal charlist and I was just calling
to_string()
on it.But now the original example code:
Will give the error referencing the Erlang spec:
as:
We can copy paste that contract into our own Elixir module, and it compiles and works with dialyzer.
Gives:
One possible issue still outstanding is that an Erlang variable could contain an ampersand. Currently that throws an error in the parser, I'm not sure why though.