www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24055] New: is(x == __parameters) does not work on function

https://issues.dlang.org/show_bug.cgi?id=24055

          Issue ID: 24055
           Summary: is(x == __parameters) does not work on function
                    pointer/delegate types
           Product: D
           Version: D2
          Hardware: All
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P3
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: destructionator gmail.com

The bugzilla search found this old thing with a similar title but different
body:
https://issues.dlang.org/show_bug.cgi?id=10557

that was about default params, but this is about the thing as a whole. Notice
the following:

---
void function(int) fp;
void delegate(int) dg;

static assert(is(typeof(fp) == __parameters)); // fails, but should succeed per
spec

static assert(is(typeof(*fp) == __parameters)); // OK, this is how you extract
in current system

static assert(is(typeof(dg) == __parameters)); // fails but should succeed per
spec

// this is how you extract in current impl
static if(is(typeof(dg) FP == delegate))
        static assert(is(FP == __parameters)); // OK
else
        static assert(0);
---

(you will have to comment one or the other test to actually see the failure)


The spec says: https://dlang.org/spec/expression.html#IsExpression

===
__parameters    the parameter sequence of a function, delegate, or function
pointer. This includes the parameter types, names, and default values.
===

The spec specifically states it should take a delegate or function pointer
directly.


Has failed in all dmd versions I've tried.

--
Jul 24 2023