josefs / Gradualizer

A Gradual type system for Erlang
MIT License
612 stars 35 forks source link

Unified error terms and text #49

Open gomoripeti opened 5 years ago

gomoripeti commented 5 years ago

It would be good to have an option to return errors as erlang terms (when called from Erlang, not cli).

This requires unifying and documenting the error terms, each one having the same structure (common fields in same position: eg filename, line number, expected type etc.)

Also the default formatter (used by the cli) could have a format similar to other tools, like the compiler: file-name:line-number:error-text

zuiderkwast commented 5 years ago

For a type error on the form of an expression E not matching a type T, I suggest the simple structure {type_error, E, T} where E and T are abstract syntax. Line number can be extracted from E. This would cover many of the currently different type errors.

Zalastax commented 5 years ago

@josefs can we get your blessing to make this happen? I expect that I can dish out a PR addressing this issue before the week ends if we can agree on the format.

zuiderkwast commented 5 years ago

I can answer yes on this question. Almost certain that Josef doesn't mind that you sort this out!

josefs commented 5 years ago

@Zalastax, go wild! I'd love to see this happen.