Repository navigation
D111 remainder (#2271): collecting view elements copies them; callable returned views keep their origin - #2384
Merged
Merged
Conversation
…ble's returned view keeps its origin
Two defects closed the last D111 shape ( and the annotated ):
1. Origin erasure at callable values. check_callable_value_call
recorded result origins only for a literal-closure callee (from its
captures); a call through a callable VALUE (a field, a parameter)
recorded none, so Mapped.next's summary said its element originated
nowhere — and, worse, a view of a dying local returned through
compiled. The fn type's declared origin now decides (D39):
a result that is or holds a view originates from the callable
value (its captures, through-viewed) and from every view-bearing
argument (a &T argument through its pointee, an ephemeral value
through its storage) — the D122 principle. The same elision seeds a
builtin intrinsic's view-carrying result from its receiver when
the resolving path recorded none (the D22 TODO at that site).
2. Collecting views built List[&T]. collect over an Iter[&T] user
implementor instantiated iter_collect at T = &T — a type no
spelling can own — so annotated demands mismatched and Mapped
chains died in Rule 6 inside std. std gains iter_collect_views
([T, I: Iter[&T]] -> List[T]); Sema dispatches a collect whose
iterator element is a Copy view there (element resolved from the
receiver's Iter impl as bound inference does), on both the user
path and, undemanded too, the builtin collect target typing.
A non-Copy view gets one diagnostic naming the explicit copy.
The map(it.clone()) stages in issue58/452, behav_d44, map_snapshot
and da_2165 are gone. New: behav_d111_collect_view_elements (all four
shapes), err_d111_callable_view_origin (the dangling return main
accepted).
Contributor
Author
|
Gate GREEN on 6f9f74a (seed-driven |
Contributor
Author
|
Battery GREEN on 6f9f74a (seed-driven, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2271's last shape:
m.keys() |> map(it) |> collect[List]()and the annotatedlet ks: List[str] = ....Origin erasure at callable values (the soundness half).
check_callable_value_callrecorded result origins only for a literal-closure callee. A call through a callable value (a field likeMapped.f, a parameter) recorded none — soMapped.next's element originated nowhere, and a view of a dying local returned throughf(k)compiled on main. The fn type's declared origin now decides (D39, the D122 principle): a result that is or holds a view originates from the callable value (its captures, through-viewed) and from every view-bearing argument — a&Targument through its pointee, an ephemeral value through its storage. Pinned byerr_d111_callable_view_origin. The same elision seeds a builtin intrinsic's view-carrying result from its receiver when the resolving path recorded none (the D22 TODO at that site).Collecting views built
List[&T].collectover anIter[&T]implementor instantiatediter_collectatT = &T, a type no spelling can own: annotated demands mismatched andMappedchains died in Rule 6 inside std. std gainsiter_collect_views[T, I: Iter[&T]] -> List[T]; Sema dispatches a collect whose iterator element is a Copy view there (element resolved from the receiver'sIterimpl exactly as bound inference does), on the user path and, undemanded too, in builtin collect target typing. A non-Copy view gets one diagnostic naming the explicit copy.The
map(it.clone())stages in issue58/452,behav_d44_map_traversal_views,map_snapshot_casesandda_2165are gone;behav_d111_collect_view_elementscovers annotated, unannotated, return-demand and builtin-iterator shapes. Note the parser half of the issue comment did not reproduce (it was the reserved parameter nameit; filed as #2382). A method-formcollectICE found alongside is #2383, pre-existing on main.Iterate evidence: stage1 runs the new + touched fixtures (9 files) green,
check src/main.wok under the new origin rules, census --diff clean,audit:resolutionclean. Gate/battery evidence follows.