First Draft: opUnwrapIfTrue

Per Nordlöw per.nordlow at gmail.com
Wed Mar 4 08:50:42 UTC 2026


On Thursday, 26 February 2026 at 13:53:41 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
> The DIP: 
> https://gist.github.com/rikkimax/21242118e3bc1bf5f28024c2cdc33557

Nice.

Regarding the lowering

```d
if (Result!int result2 = result, result2.opCast!bool) {
	scope(exit) result2.destroy;
	...
} else {
	result2.destroy;
}
```

are

```d
	scope(exit) result2.destroy;
	result2.destroy;
```

eagerly elided when `__traits(needsDestruction, typeof(result2))` 
is false or are the injected the lower regardless and then later 
elided? Just checking to make sure the lowering doesn't inject 
AST unneccesary nodes.


More information about the dip.development mailing list