Skip to content

Remove requirement that function / builtin return values are always consumed #2138

Description

@ben-clayton

Background:

#1413 proposed that call statements may only call a function or builtin with no return value, and that call expressions must be consumed by a statement. #1651 introduced this rule with the line:

If the called function returns a value, that value must be consumed either through assignment, evaluation in another expression or through use of the ignore built-in function

ignore() was added in #1587, and its original use was to allow an "escape-hatch" for cases where the user needs to call a function that returns a value, and doesn't actually want to use that returned value.

Since ignore() was added to the spec, it has found additional use for ensuring that binding points are referenced by a given entry point (this is possibly a Tint <-> Dawn implementation detail that needs spec clarification).

In #2115 we're discussing replacing ignore() with _.


We're now getting feedback 1 from users that this original rule may be too restrictive.

For example: it's common to want to call atomicAdd() without using the returned "old" value.

I'm filing this issue so we can re-evaluate whether the rule to always consume a call return value is worth keeping.

Activity

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

    wgslWebGPU Shading Language Issues

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions