Skip to content

Check a type-erased query by calling it - #2364

Merged
ericniebler merged 1 commit into
NVIDIA:mainfrom
ispeters:function-requires-stop-token
Oct 30, 2026
Merged

ericniebler merged 1 commit into
NVIDIA:mainfrom
ispeters:function-requires-stop-token

Conversation

@ispeters

Copy link
Copy Markdown
Contributor

A type-erased receiver answers a declared query R(Q, Args...) by calling Q()(get_env(rcvr), args...) on the wrapped receiver's environment, but type erasure checks something narrower: whether the environment has a query member for Q. The two differ for a query with a default answer. For example, get_domain(env) answers default_domain for an environment with no get_domain member, so an exec::any_sender or exec::function declaring
default_domain(get_domain_t) noexcept can answer the query in such an environment, but can't be connected there.

This diff checks the call instead: the environment satisfies a declared query when calling the query object on it is well-formed, converts to the declared result type and, if the declaration is noexcept, isn't potentially throwing. For the standard queries, the two checks agree wherever the environment has its own query member, so every environment accepted before is still accepted; what's new is that a query's default answer now counts. Only get_domain and get_stop_token have one, and any_sender's existing special cases for get_stop_token still decide those declarations.

@copy-pr-bot

copy-pr-bot Bot commented Oct 25, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@ericniebler

Copy link
Copy Markdown
Collaborator

/ok to test 13c8af9

@ericniebler
ericniebler force-pushed the function-requires-stop-token branch from 13c8af9 to 06e17e9 Compare October 26, 2026 23:46
@ericniebler

Copy link
Copy Markdown
Collaborator

i've merged #2361. are changes needed to this PR?

@ispeters
ispeters force-pushed the function-requires-stop-token branch from 06e17e9 to 91a54e7 Compare October 27, 2026 00:38
@ispeters

Copy link
Copy Markdown
Contributor Author

i've merged #2361. are changes needed to this PR?

Yep; the comment on #2361 just needed to be applied here. I've done that and force-pushed so this is ready to merge.

@ericniebler

Copy link
Copy Markdown
Collaborator

/ok to test 91a54e7

@ericniebler
ericniebler force-pushed the function-requires-stop-token branch from 91a54e7 to c352ed3 Compare October 28, 2026 19:44
@ericniebler

Copy link
Copy Markdown
Collaborator

/ok to test c352ed3

A type-erased receiver answers a declared query `R(Q, Args...)` by
calling `Q()(get_env(rcvr), args...)` on the wrapped receiver's
environment, but type erasure checks something narrower: whether the
environment has a `query` member for `Q`. The two differ for a query
with a default answer. For example, `get_domain(env)` answers
`default_domain` for an environment with no `get_domain` member, so an
`exec::any_sender` or `exec::function` declaring
`default_domain(get_domain_t) noexcept` can answer the query in such an
environment, but can't be connected there.

This diff checks the call instead: the environment satisfies a declared
query when calling the query object on it is well-formed, converts to
the declared result type and, if the declaration is `noexcept`, isn't
potentially throwing. For the standard queries, the two checks agree
wherever the environment has its own `query` member, so every
environment accepted before is still accepted; what's new is that a
query's default answer now counts. Only `get_domain` and `get_stop_token`
have one, and `any_sender`'s existing special cases for `get_stop_token`
still decide those declarations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ispeters
ispeters force-pushed the function-requires-stop-token branch from 4c98219 to 0efe8bf Compare October 30, 2026 02:34
@ericniebler

Copy link
Copy Markdown
Collaborator

/ok to test 0efe8bf

@ericniebler
ericniebler merged commit 9959aad into NVIDIA:main Oct 30, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants