Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot unify recursive union #224

Open
lpil opened this issue Jan 2, 2018 · 2 comments
Open

Cannot unify recursive union #224

lpil opened this issue Jan 2, 2018 · 2 comments

Comments

@lpil
Copy link
Contributor

lpil commented Jan 2, 2018

I attempted to define the iolist type like so:

type iolist
  = list iolist
  | string

val my_iolist : iolist
let my_iolist =
  ["h", ["i", ["!"]]]

This does not compile

louis ~/projects/learning-alpaca/hello_world $ rebar3 eunit
===> Verifying dependencies...
===> Compiling hello_world
===> Alpaca 0.2.8: compiling hello_world.alp

===> Alpaca compile error:
(╯°□°)╯︵ ┻━┻ {cannot_unify,hello_world,0,t_string,error}
Sorry, we do not have a proper message for this error yet.

Is this a bug or by design?

Thanks,
Louis

@j14159
Copy link
Collaborator

j14159 commented Jan 2, 2018

Definite bug, thanks for finding this! The error atom suggests that the typer is assuming success somewhere where it should be checking for an error tuple, e.g. {error, _}. This can happen because typ_of/2 usually returns {Type, NextTypeVariableNumber :: integer()} or {error, term()}.

@j14159
Copy link
Collaborator

j14159 commented Feb 5, 2018

I think I know what this is now, roughly: alpaca_typer.find_covering_types/4 (or rather try_types/6) isn't looking at list iolist as a possible alias for list string. Not 100% sure this is it but looking likely.

@j14159 j14159 closed this as completed in afd6a13 Feb 6, 2018
@j14159 j14159 reopened this Feb 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants