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

legal casts #177

Closed
jnfoster opened this issue Apr 26, 2017 · 4 comments
Closed

legal casts #177

jnfoster opened this issue Apr 26, 2017 · 4 comments

Comments

@jnfoster
Copy link
Contributor

jnfoster commented Apr 26, 2017

Currently we write:

A struct/header can be cast to another struct/header if and only if they have the same number of fields and all the fields in the source can be recursively cast to the corresponding fields in the destination.

But we allow tuples and lists to be assigned to struct/headers. So it seems that this should be generalized to struct/header/tuple/lists too?

FWIW, the implementation is stricter than I'd expect as a programmer:
p4lang/p4c#529

@mihaibudiu
Copy link
Contributor

I think that this claim is not implemented as described in the compiler.
In fact, the fields have to be exactly the same types.

Indeed, the type of a ListExpression in the compiler is a tuple, and we allow tuples to be assigned to structs and headers. We have an open issue about assigning lists to headers.

So this paragraph has to be expanded.

@jnfoster
Copy link
Contributor Author

Indeed. Now we have a placeholder so we don't forget to address this.

@mihaibudiu
Copy link
Contributor

We should assign these issues to people to make sure they are covered.

@mihaibudiu
Copy link
Contributor

We should also forbid casts that do not involve only base types.

mihaibudiu pushed a commit that referenced this issue May 8, 2017
jnfoster added a commit that referenced this issue May 9, 2017
@jnfoster jnfoster closed this as completed May 9, 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

2 participants