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

Fix IRAnything #56

Closed
schani opened this issue Jul 29, 2017 · 0 comments
Closed

Fix IRAnything #56

schani opened this issue Jul 29, 2017 · 0 comments

Comments

@schani
Copy link
Member

schani commented Jul 29, 2017

IRAnything currently serves two purposes in the IR:

  1. In inference, to signify a type we know nothing about. The only way for it to come about is as the element type of an empty array.

  2. In generation, for any type, which we translate to object in C#.

We make no explicit distinction between the two in the code, i.e. they are one and the same.

That mostly works for now, but we will run into trouble if our inference algorithm ever wants to distinguish between the two. In addition to that, JSON Schema does have a representation for "any type", but our unification algorithm does not treat IRAnything as "any type", so we can't use and expect to get correct results. For example, if we treat "any type" as IRAnything, we would unify an array that contains one "any type" and one integer as an array containing integers. The correct unification is an array containing "any type".

If we had IRNoInformation and IRAny, unification would look like this:

unify IRNoInformation x = x
unify IRAny x = IRAny

Of course, to preserve more type information we could still do

unify IRAny x = IRUnion [IRAny, x]
@schani schani added the rewrite label Aug 5, 2017
schani added a commit that referenced this issue Aug 23, 2017
IRNothing means anything, so it can also be
null.  See #56
schani added a commit that referenced this issue Aug 29, 2017
IRNothing means anything, so it can also be
null.  See #56


Original commit 282339c
@schani schani changed the title Get rid of IRNothing Get rid of IRAnything Sep 5, 2017
@schani schani changed the title Get rid of IRAnything Fix IRAnything Sep 5, 2017
schani added a commit that referenced this issue Sep 10, 2017
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

1 participant