Bug 19328 – isExpression does not allow to check conversion to delegate/function

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P4
Component
dlang.org
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-10-23T15:00:35Z
Last change time
2023-02-22T10:30:42Z
Assigned to
No Owner
Creator
RazvanN

Comments

Comment #0 by razvan.nitu1305 — 2018-10-23T15:00:35Z
The grammar allows to check if a type is convertible to a delegate through isExpression [1]. However, compiling this: template ParameterTupleOf( Fn ) { static if( is( Fn Params == function ) ) pragma(msg, "function"); else static if( is( Fn Params == delegate ) ) pragma(msg, "delegate"); else static if( is( Fn Params == Params* ) ) pragma(msg, "pointer"); else static assert( false, "Argument has no parameters." ); } Issues a parsing error. [1] https://dlang.org/spec/grammar.html#IsExpression
Comment #1 by nick — 2023-02-21T18:33:20Z
Seems to work fine now for this: void f(); alias a = ParameterTupleOf!(typeof(f)); alias b = ParameterTupleOf!(void delegate()); alias c = ParameterTupleOf!(void function());