www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23404] New: CTFE evaluation is unecessary when passing


          Issue ID: 23404
           Summary: CTFE evaluation is unecessary when passing function
                    return type as aliased template argument
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: contact lsferreira.net

The following doesn't compile, as it fails on `bar()` call because it doesn't
have the source code. Although it should.

void bar();

int foo()()
    return 1;

void weird(alias func)() {}

void main()

Although, changing the line 15 to `weird!(foo!())`, it starts working.

Eventhough they are different semantics, the CTFE engine is running
unnecessarily on the first situation, where there's no need to `weird` being

This can particularly a problem for `core.lifetime.forward!()` when, you want
to forward ref return types.

Oct 10 2022