www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23264] New: Allow __traits(parameters) in the return type or

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

          Issue ID: 23264
           Summary: Allow __traits(parameters) in the return type or
                    contract of a function
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: qs.il.paperinik gmail.com

Allow __traits(parameters) to occur in any part of the function, not only its
body and `in` and `out` contract.

The following should be legal:

  typeof(__traits(parameters))[0] f(Ts...)(Ts args) { … }

  void f(Ts...)(Ts args)
    if (__traits(parameters).length > 1)
  { … }

But they are rejected with
Error: `__traits(parameters)` may only be used inside a function

It is unmistakably clear what the intention is.

--
Jul 21 2022