www.digitalmars.com         C & C++   DMDScript  

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

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 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()()
{
    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.

--
Oct 10 2022