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 issue 23314 - Language spec falsely states that struct field inva… #3405

Merged
merged 1 commit into from
Sep 5, 2022

Conversation

pbackus
Copy link
Contributor

@pbackus pbackus commented Sep 5, 2022

…riants are checked

This behavior has never been implemented, and users should not rely on
it in their code.

…riants are checked

This behavior has never been implemented, and users should not rely on
it in their code.
@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @pbackus! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Auto-close Bugzilla Severity Description
23314 normal Language spec falsely states that struct field invariants are checked

@dlang-bot dlang-bot merged commit c84c829 into dlang:master Sep 5, 2022
pbackus added a commit to pbackus/phobos that referenced this pull request Sep 5, 2022
According to earlier versions of the language spec, checking the
invariant of a struct would also cause its fields' invariants to be
checked, recursively. SumType's invariant was added to make SumType
behave consistently with other structs in this regard.

The spec, however, was wrong: invariants of struct fields are not
checked unless the field is accessed directly, and never have been.
Thus, to make SumType behave consistently with other structs, its
invariant must be removed.

This change should not break any valid programs, since code that relies
on the failure of an invariant has undefined behavior per the spec.

Spec correction PR: dlang/dlang.org#3405
pbackus added a commit to pbackus/sumtype that referenced this pull request Sep 5, 2022
According to earlier versions of the language spec, checking the
invariant of a struct would also cause its fields' invariants to be
checked, recursively. SumType's invariant was added to make SumType
behave consistently with other structs in this regard.

The spec, however, was wrong: invariants of struct fields are not
checked unless the field is accessed directly, and never have been.
Thus, to make SumType behave consistently with other structs, its
invariant must be removed.

This change should not break any valid programs, since code that relies
on the failure of an invariant has undefined behavior per the spec.

Spec correction PR: dlang/dlang.org#3405
Phobos PR: dlang/phobos#8558
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.

3 participants