Skip to content

Facet values (like type values) can be copied around at runtime #5242

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

Merged

Conversation

danakj
Copy link
Contributor

@danakj danakj commented Apr 3, 2025

Give them a value representation of copy, and allow conversions between two facet values of the same type to work.

Convert was assuming that facet values are compile time constants, but thye can also be runtime values. In that case, we have no support for converting to a different facet value of a different facet type. But if the types are equal then it's all fine.

In theory it seems that we should be able to convert if the target facet type can be found through the source value's FacetType. But currently that happens through impl lookup and it requires constant values. Adding a test for this.

Related to #5241

@github-actions github-actions bot requested a review from zygoloid April 3, 2025 18:49
@danakj
Copy link
Contributor Author

danakj commented Apr 3, 2025

Marked this as closing the leads question, as I think this is a potential answer and it's hinted at by the lowering test.

Give them a value representation of copy, and allow conversions between
two facet values of the same type to work.

Convert was assuming that facet values are compile time constants, but
thye can also be runtime values. In that case, we have no support for
converting to a different facet value of a different facet type. But if
the types are equal then it's all fine.

In theory it seems that we should be able to convert if the target facet
type can be found through the source value's FacetType. But currently
that happens through impl lookup and it requires constant values. Adding
a test for this.
@danakj danakj force-pushed the facet-values-are-copy-valuerepr branch from 47c4e8f to a9d8436 Compare April 3, 2025 18:54
@danakj danakj added this pull request to the merge queue Apr 3, 2025
@zygoloid
Copy link
Contributor

zygoloid commented Apr 3, 2025

I think if you want this to close the leads issue, we should have a proper diagnostic for conversion of a runtime facet value rather than a TODO. It'd be good to also get another lead to look at that and confirm they like the direction.

Alternatively we can keep the TODO diagnostic and land this as-is (but without the "Closes #5241"), and update once the leads issue is closed.

@zygoloid zygoloid removed this pull request from the merge queue due to a manual request Apr 3, 2025
@danakj
Copy link
Contributor Author

danakj commented Apr 3, 2025

I think if you want this to close the leads issue, we should have a proper diagnostic for conversion of a runtime facet value rather than a TODO. It'd be good to also get another lead to look at that and confirm they like the direction.

Alternatively we can keep the TODO diagnostic and land this as-is (but without the "Closes #5241"), and update once the leads issue is closed.

Got it, will leave it open.

@danakj danakj added this pull request to the merge queue Apr 3, 2025
Merged via the queue into carbon-language:trunk with commit 164310c Apr 3, 2025
8 checks passed
@danakj danakj deleted the facet-values-are-copy-valuerepr branch April 3, 2025 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants