asummers / erlex

Convert Erlang style structs and error messages to equivalent Elixir.
Other
34 stars 17 forks source link

Type related issue #43

Open OvermindDL1 opened 5 years ago

OvermindDL1 commented 5 years ago

Nothing big, just noticing a potential couple bugs as I was running a new BEAM typer (it's a negative ML typer, not a weak positive typer like Dialyzer, Gradualizer, would make for an awesome addition into Dialyxir so I don't have to publish and keep up Gradualixir ^.^) over one of my projects and erlex had a couple things pop up that aren't entirely, though some are it's fault:

_build/test/lib/erlex/ebin/Elixir.Erlex.beam: The variable _byte@1 on line 269 is expected to have type integer() but it has type term()
_build/test/lib/erlex/ebin/Elixir.Erlex.beam: The pattern [61, 58, 61] on line 0 does not have type:
infix :: 'Elixir.String':t()
_build/test/lib/erlex/ebin/Elixir.Erlex.beam: The pattern [112, 97, 116, 116, 101, 114, 110, 32 | _rest@1] on line 0 does not have type:
pattern :: 'Elixir.String':t()

_build/test/lib/erlex/ebin/parser.beam: The pattern {ok, [{atom, _, Symbol}], _} on line 74 doesn't have the type {error,
           ErrorInfo :: error_info(),
           non_neg_integer() | {line(), column()}} |
          {ok,
           Tokens :: tokens(),
           non_neg_integer() | {line(), column()}}

And the lexer.erl file is fine.

In essence it's saying that:

This was mostly just for fun, and the fact erlex only has 4 issues reported unlike the 4000 that most other libraries have. ^.^;

asummers commented 5 years ago

That's actually showing a bug in Gradualixir (I think?). Pretty much everywhere I'm listing a String.t() in the typespecs as the input type for pretty_print_X should be a charlist() but it's not telling us that. Looking at my typespecs more closely, they have some really deep issues I need to address, but the type checks on your end are not telling us about them.

OvermindDL1 commented 5 years ago

It's still heavily in dev, though thus far what it detects has seemed pretty accurate, it just tends to crash or give excess errors about what it doesn't (like maps barely have support so far). I think it lets the typespec mostly override a function similar to dialyzer but I'm unsure yet, barely playing with it so far. However this library is small yet still complicated enough that it makes a great test bed for my experiments. :-)

christhekeele commented 4 months ago

Just an FYI @OvermindDL1 that this project now lives here, feel free to re-open this issue over there if it's still a thing.