Actually we do have checked PHVs for lateral references, earlier in create_lateral_join_info. But that time we only marked lateral_relids and direct_lateral_relids, without remembering the lateral expressions. So I'm wondering whether we can fix that by fetching Vars (or PHVs) of lateral references within PlaceHolderVars and remembering them in the baserel's lateral_vars.