Bug 14878 – destructor of lambda parameter not included in speculative @safe check

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-08-06T11:25:00Z
Last change time
2015-10-04T18:20:11Z
Assigned to
nobody
Creator
code

Comments

Comment #0 by code — 2015-08-06T11:25:57Z
cat > bug.d << CODE struct T { ~this() @system {} } static assert(!__traits(compiles, (T) @safe {})); static assert(!is(typeof((T) @safe {}))); CODE ---- This is an idiom that emerged from working on dup [¹] to quickly check whether a struct has a @safe dtor or postblit. The postblit check `__traits(compiles, (T b) { T a = b;})` works fine. [¹]: https://github.com/D-Programming-Language/druntime/blob/ab41e5ec1e89135b9aa9811f28f07dcf46112b82/src/object.d#L3166
Comment #1 by k.hara.pg — 2015-08-06T13:54:22Z
(In reply to Martin Nowak from comment #0) > static assert(!__traits(compiles, (T) @safe {})); > static assert(!is(typeof((T) @safe {}))); `(T) @safe {}` is a lambda with untyped parameter name T. Following static asserts work as you expects. static assert(!__traits(compiles, (T b) @safe {})); static assert(!is(typeof((T b) @safe {})));
Comment #2 by code — 2015-08-06T22:59:48Z
(In reply to Kenji Hara from comment #1) > Following static asserts work as you expects. > > static assert(!__traits(compiles, (T b) @safe {})); > static assert(!is(typeof((T b) @safe {}))); I'm sure I tried that, but apparently not on both at the same time ;). It didn't occur to me though that `(T) @safe {}` was parsed as polymorphic lambda with `T` being the parameter's name.
Comment #3 by github-bugzilla — 2015-08-07T09:15:19Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/901908ec7f38b1d9b6a7d291bbb858f60c12f0cb remove workaround for invalid bug 14878 - have to use `(T t) @safe {}` - turns out that T in `(T) @safe {}` is the parameter name of a polymorphic lambda not the parameter type of a function literal https://github.com/D-Programming-Language/phobos/commit/950c5519b48ecadd85840bd5de719d12b43b5fb0 Merge pull request #3532 from MartinNowak/fixup3527 remove workaround for invalid bug 14878
Comment #4 by github-bugzilla — 2015-10-04T18:20:11Z