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: Optimize datatype wrappers only in the absence of trait parents #5234

Merged
merged 3 commits into from Mar 22, 2024

Conversation

RustanLeino
Copy link
Collaborator

This PR makes two changes to when the "erase datatype wrapper" optimization is engaged.

  • The optimization is disabled if the datatype implements any traits. (Previously, the optimization was still allowed under this condition, which had caused malformed code, see issue Datatype erasure and traits don't play together #5233.)
  • Allow the optimization in the presence of ghost fields. (Previously, the optimization was disabled if the datatype contained any fields. But ghost fields pose no problems for compilation.)

Fixes #5233

How has this been tested?

The tests (including the test case from the bug report) were added to comp/ErasableTypeWrappers.dfy.

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

Fixes dafny-lang#5233

As a bonus, allow the optimization when there are no _compiled_ fields (previously, the optimization was disabled when _any_ fields were present).
@RustanLeino RustanLeino marked this pull request as ready for review March 21, 2024 21:26
@keyboardDrummer keyboardDrummer enabled auto-merge (squash) March 22, 2024 11:10
@keyboardDrummer keyboardDrummer merged commit ece9b76 into dafny-lang:master Mar 22, 2024
20 checks passed
@RustanLeino RustanLeino deleted the issue-5233 branch March 22, 2024 16:20
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

Successfully merging this pull request may close these issues.

Datatype erasure and traits don't play together
2 participants