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

Comments

@jnfoster
Copy link
Contributor

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

@mbudiu-vmw

This comment has been minimized.

Copy link
Contributor

commented Apr 26, 2017

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

This comment has been minimized.

Copy link
Contributor Author

commented Apr 26, 2017

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

@mbudiu-vmw

This comment has been minimized.

Copy link
Contributor

commented Apr 26, 2017

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

@mbudiu-vmw

This comment has been minimized.

Copy link
Contributor

commented May 8, 2017

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

mbudiu-vmw added a commit that referenced this issue May 8, 2017
jnfoster added a commit that referenced this issue May 9, 2017

@jnfoster jnfoster closed this May 9, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.