[Issue 23404] New: CTFE evaluation is unecessary when passing function return type as aliased template argument
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Mon Oct 10 20:26:10 UTC 2022
    
    
  
https://issues.dlang.org/show_bug.cgi?id=23404
          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 at puremagic.com
          Reporter: contact at 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()()
{
    bar();
    return 1;
}
void weird(alias func)() {}
void main()
{
    weird!(foo());
}
```
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
CTFE-able.
This can particularly a problem for `core.lifetime.forward!()` when, you want
to forward ref return types.
--
    
    
More information about the Digitalmars-d-bugs
mailing list