Bug 18910 – Non-compile-time-constant parameter default values not respected when passed as alias to a template function (with some indirection)

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-05-26T17:57:20Z
Last change time
2022-01-28T09:55:11Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
Neia Neutuladh

Comments

Comment #0 by dhasenan — 2018-05-26T17:57:20Z
Test case: --- import std.stdio; int protoss(alias func)() { return func(4); } int zerg(immutable int q) { int getSecondArgument(int a, int b) { writefln("getSecondArgument of %s %s", a, b); return b; } return protoss!((int a, int b = q) => getSecondArgument(a, b))(); } void main(string[] args) { zerg(10).writeln; } --- Expected output: getSecondArgument of 4 10 10 Actual output: getSecondArgument of 4 0 0 Simplified cases of this do result in an error message, so it's probably just a case of extending the current error check, or reordering an optimization or something.
Comment #1 by dhasenan — 2018-05-26T17:59:26Z
Comment #2 by ag0aep6g — 2018-05-26T18:00:45Z
Duplicate of issue 18909?
Comment #3 by razvan.nitu1305 — 2022-01-28T09:55:11Z
*** This issue has been marked as a duplicate of issue 22540 ***