Skip to content

Record views: declare every view origin as through, self included (D122/D187 use two declarations for one meaning) #3020

Done

Description

@ehartford

Record views (D122, §16.2b.6): a method hosted on a record view (n.first_child(), a.pick(b, …)) declares its result as viewing self's own storage (facade_declare_view_of_param(msig, 0), SemaFacade.w verify_facade_record_return). That gives the right answer only because the call-site rule makes an in-place receiver transparent (SemaCheck.w record_call_view_origins_args: in_place_recv and not views_storage). D187 (#2965) had to declare the second origin of returns borrow T from params 0, 1 as "views through what the parameter views" (facade_declare_view_through_param), because for a non-receiver &T argument "of storage" pins the result to the argument's local binding.

Two declarations for one meaning. A record view &T points at C memory owned by the record's origin, so a result borrowed through any view parameter, self included, views what that view views, never the parameter's binding. The principled fix: declare every record-view origin "through", and let the receiver stop relying on the in-place-receiver rule for this case. Fixture: test/behavior/behav_d187_borrow_from_two_params.w (same_doc, either) and test/behavior/behav_d122_borrow_through_borrow.w must keep passing; err_d122_child_outlives_document must keep refusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions