dlang.org icon indicating copy to clipboard operation
dlang.org copied to clipboard

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

Open ljmf00-wekaio opened this issue 1 year ago • 2 comments

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))

ljmf00-wekaio avatar Nov 27 '25 12:11 ljmf00-wekaio

can i work on this issue?

Demiserular avatar Dec 30 '25 08:12 Demiserular

Yes! Note that this s a spec issue and not a compiler issue.

thewilsonator avatar Dec 30 '25 10:12 thewilsonator