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

ADT extension crashes when dealing with non-pointer ADTs #1

Closed
krame505 opened this issue Jun 10, 2015 · 1 comment
Closed

ADT extension crashes when dealing with non-pointer ADTs #1

krame505 opened this issue Jun 10, 2015 · 1 comment

Comments

@krame505
Copy link
Member

The ADT extension seems to be crashing when matching on a dereferenced ADT. The following is a (mostly) minimal test case:

typedef datatype Node Node;

datatype Node {
  Leaf (int);
};

int main() {
  Node n = *Leaf(4);

  match (n) {
    Leaf (i): ;
  };
}

It is also unclear how to nicely handle non-pointer ADTs; We allow the user to create them and pass them around, but they always have to be written as a pointer and be used as a pointer to do anything with them. Would it make sense to automatically take the address when a match is performed on a non-pointer? Otherwise we should consider making datatypes always pointers behind the scenes, and just hiding this from the user. Also, why are ADTs pointers at the top level, anyway?

@tedinski
Copy link
Member

Matching on a non-pointer should probably be a type error. Can you fix it?

If you'd like to do so as a learning experience, it would also be nice to try forking it, fixing the problem in a branch of your fork, and submitting a pull request that would close this issue when merged.

Some pages documenting this stuff:
http://stackoverflow.com/a/14680805
https://github.com/blog/1506-closing-issues-via-pull-requests

Feel free to ask any questions.

Node n = *Leaf(4);

Memory leak, btw. This is why it's probably not worthwhile to accept matching on non-pointers. The memory management aspects will be difficult.

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