Skip to content

Spec is inconsistent with associative arrays and arrays regarding prefix and postfix expression equivalence #4335

Description

@ljmf00-wekaio

Currently specs says:

11.3.1.2. Increment and Decrement: [...] the result of prefix ++ and -- is the lvalue after the side effect has been effected.
11.3.1.4. Increment and Decrement: [...] the result of postfix ++ and -- is an rvalue just before the side effect has been effected.

The problem is that, mentioned equivalent expression works for arrays but not for associative arrays:

expr++; (ref x){auto t = x; ++x; return t;}(expr)

Can we clarify it to match the Construction or Assignment on Setting AA Entries point, because:

(ref x){auto t = x; ++x; return t;}(aa["hello"])

will fail on lookup. It's more like:

expr++; (ref x){auto t = x; ++x; return t;}(aa.require("hello", int.init))

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions