Skip to content

Revert changes to inferred valid age that are not consistent with edges model assumed by precompile #58289

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Apr 30, 2025

Reverts only the code from #58254, not the docs

This adds unsound behavior to the Compiler in a doc PR that is supposed to be about increasing soundness. It isn't easily observable behavior, since the added code only triggers if code gets precompiled and saved and the Method gets used before its official "primary" world, but it can lead to unpredictable and inconsistent inference results.

@vtjnash
Copy link
Member Author

vtjnash commented Apr 30, 2025

For example, the following code (invoking the method to add 1+1 with assume_effect added) is well-formed (if discouraged), and is not UB as implied by #58254:

julia> w = Base.get_world_counter(); Base.@assume_effects :consistent add(a, b) = a + b; Core.invoke_in_world(w, Core.invoke, add, @which(add(1, 1)), 1, 1)
2

I tried to ask for this code to be removed from the PR, but I guess I wasn't precise enough.

FIXED: nothrow->consistent, since it is only an issue for consistent code (see comment below)

Keno
Keno previously requested changes Apr 30, 2025
Copy link
Member

@Keno Keno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the revert is productive. Can you please be more precise what your actual concern is?

@Keno
Copy link
Member

Keno commented Apr 30, 2025

For example, the following code (invoking the method to add 1+1 with assume_effect added) is well-formed (if discouraged), and is not UB as implied by #58254:

The world age bound affects the :consistent annotation, so the example is not applicable. However, with the :consistent annotation, the point of the change is precisely to not apply the :consistent annotation in this scenario to comply with the tightened specification.

@vtjnash
Copy link
Member Author

vtjnash commented Apr 30, 2025

Okay, I fixed the example above to use consistent instead. I see: you want to express that the method is not valid before it was defined. That seems still incorrect though, since there's nothing semantically relevant to the method itself about that specific world. The PR also failed to define an edge against that method, so re-validation later will result in this being re-added to the valid range in unpredictable ways. For user-friendliness, we usually also have edges against the opposite branch now too (not required for correctness, but we normally do have them):

else
                update_valid_age!(sv, WorldRange(1, m.primary_world - 1))

@vtjnash vtjnash force-pushed the revert-58254-kf/consistentdoc branch from d77dcb6 to c688e27 Compare April 30, 2025 20:38
@vtjnash vtjnash dismissed Keno’s stale review April 30, 2025 20:39

update pushed to keep the doc changes

@vtjnash vtjnash changed the title Revert "Strengthen language around @assume_effects :consistent" Revert changes to inferred valid age that are not consistent with edges model assumed by precompile Apr 30, 2025
@Keno
Copy link
Member

Keno commented Apr 30, 2025

you want to express that the method is not valid before it was defined.

The method is valid, but the consistency annotation is not

@vtjnash vtjnash added the revert This reverts a previously merged PR. label May 10, 2025
)"

This reverts the invalid functional changes from commit
d7cd271, keeping only the doc updates.
@vtjnash vtjnash force-pushed the revert-58254-kf/consistentdoc branch from c688e27 to a80b5aa Compare May 28, 2025 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
revert This reverts a previously merged PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants