Bug 12647 – Allow specifying lazy parameter function attributes and infer them when possible

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-04-25T13:57:54Z
Last change time
2024-12-13T18:20:03Z
Keywords
industry, pull, rejects-valid
Assigned to
No Owner
Creator
Kenji Hara
Depends on
12622, 12649
Blocks
12645, 16240
Moved to GitHub: dmd#18819 →

Comments

Comment #0 by k.hara.pg — 2014-04-25T13:57:54Z
This code should work, but doesn't. void assertThrown(E)(lazy E expression) { expression(); } void main() nothrow { assertThrown( 0 ); } Currently lazy parameter evaluation `epxression()` is treated as @safe and pure, but does not marked as nothrow. It's a bug.
Comment #1 by k.hara.pg — 2014-04-25T14:00:15Z
Also should be inferred as @nogc.
Comment #2 by k.hara.pg — 2014-04-25T14:04:57Z
Comment #3 by k.hara.pg — 2014-04-28T05:25:16Z
*** Issue 12664 has been marked as a duplicate of this issue. ***
Comment #4 by pro.mathias.lang — 2015-02-17T06:57:25Z
*** Issue 7267 has been marked as a duplicate of this issue. ***
Comment #5 by per.nordlow — 2016-07-06T13:25:22Z
If this gets fixed the bug comment at file:///home/per/ware/dlang_org/web/phobos-prerelease/std_algorithm_comparison.html#.either should be removed.
Comment #6 by greeenify — 2016-12-23T06:01:08Z
This a really annoying limitation during the process of annotating Phobos unittests. It leads from a nice one-liner, e.g. assertThrown!AssertError(arr.stride(0)); to be replaced with 10 lines: bool passed = false; scope (success) assert(passed); try { cast(void) arr.stride(0); } catch (AssertError unused) { passed = true; }
Comment #7 by greeenify — 2016-12-24T04:58:49Z
There's a newer attempt by LemonBoy: https://github.com/dlang/dmd/pull/6348
Comment #8 by lucia.mcojocaru — 2017-03-01T11:46:39Z
*** Issue 17136 has been marked as a duplicate of this issue. ***
Comment #9 by robert.schadek — 2024-12-13T18:20:03Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18819 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB