Skip to content

Document that calling a method on a struct rvalue is allowed #4234

Open
@ntrel

Description

@ntrel
Contributor

Even though the hidden this parameter is ref.

struct S
{
    int i;
    int f() => ++i;
}

void main()
{
    //S().i++; // cannot modify, `S().i` is not an lvalue
    assert(S().f() == 1); // OK
}

PR incoming.

Activity

added a commit that references this issue on Apr 27, 2025
fd911c0
linked a pull request that will close this issue on Apr 27, 2025
added a commit that references this issue on Apr 27, 2025
d4d306c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @ntrel

      Issue actions

        Document that calling a method on a struct rvalue is allowed · Issue #4234 · dlang/dlang.org