Issue 24055 - is(x == __parameters) does not work on function pointer/delegate types
Summary: is(x == __parameters) does not work on function pointer/delegate types
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All Windows
: P3 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2023-07-24 16:02 UTC by Adam D. Ruppe
Modified: 2023-07-25 06:53 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Adam D. Ruppe 2023-07-24 16:02:28 UTC
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.
Comment 1 Dlang Bot 2023-07-24 20:03:22 UTC
@dkorpel created dlang/dmd pull request #15453 "Fix 24055 - is(x == __parameters) does not work on function pointers" fixing this issue:

- Fix 24055 - is(x == __parameters) does not work on function pointers

https://github.com/dlang/dmd/pull/15453
Comment 2 Dlang Bot 2023-07-25 06:53:05 UTC
dlang/dmd pull request #15453 "Fix 24055 - is(x == __parameters) does not work on function pointers" was merged into master:

- 0c1e94f17883ee9c6b705dd94b674b18b77fd413 by Dennis Korpel:
  Fix 24055 - is(x == __parameters) does not work on function pointers

https://github.com/dlang/dmd/pull/15453