Bug 16653 – ParameterDefaultValueTuple fails to compile when function has lazy param

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-11-01T06:54:00Z
Last change time
2017-01-16T23:26:02Z
Assigned to
lucia.mcojocaru
Creator
goldmax3000

Comments

Comment #0 by goldmax3000 — 2016-11-01T06:54:25Z
This code: import std.traits; void f(lazy int x = 0) {} pragma(msg, ParameterDefaultValueTuple!f); gives compile error /opt/compilers/dmd2/include/std/traits.d-mixin-1216(1216): Error: lazy variables cannot be lvalues /opt/compilers/dmd2/include/std/traits.d(1253): Error: template instance std.traits.ParameterDefaultValueTuple!(f).Get!0LU error instantiating /opt/compilers/dmd2/include/std/traits.d(1256): instantiated from here: Impl!0LU /d321/f969.d(5): instantiated from here: ParameterDefaultValueTuple!(f) /d321/f969.d(5): while evaluating pragma(msg, ParameterDefaultValueTuple!(f))
Comment #1 by lucia.mcojocaru — 2016-12-20T11:28:16Z
The cause of the issue is the way the template code is written in phobos: https://github.com/dlang/phobos/blob/master/std/traits.d#L1225 It looks like this is expected for lazy variables: http://forum.dlang.org/thread/[email protected] Should we support the ParameterDefault template for functions with lazy parameters?
Comment #2 by lucia.mcojocaru — 2016-12-20T12:32:03Z
PR with fix here: https://github.com/dlang/phobos/pull/4977 This works for me now: import std.traits; int main() { void f(lazy int x = 0) {} pragma(msg, ParameterDefaultValueTuple!f); return 0; }
Comment #3 by github-bugzilla — 2016-12-21T13:10:01Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/48398dbd0f42d258461332b619939e550be430de fix issue 16653 https://github.com/dlang/phobos/commit/64ed49be5ab973a7d260b014dd39170a16ae37b1 Merge pull request #4977 from somzzz/issue_16653 fix issue 16653 - ParameterDefaultValueTuple fails to compile when function has lazy param
Comment #4 by ketmar — 2017-01-06T13:54:17Z
and now one can't have argument with name `value` anymore, 'cause it conflicts with `value` variable in fix. dunno if it worth opening new bug, tho, 'cause fix is not in any release yet, so it can be... fixed right here. ;-)
Comment #5 by destructionator — 2017-01-06T15:11:47Z
Comment #6 by github-bugzilla — 2017-01-06T18:15:53Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/5febcef46617f15738e77e5e732ab9e37aa82649 better workaround for issue 16653, fix ketmar comment https://github.com/dlang/phobos/commit/33b73851297ab2dd881f931ccf3de7849d838c1b Merge pull request #5020 from adamdruppe/issue_16653 better workaround for issue 16653, fix ketmar comment
Comment #7 by github-bugzilla — 2017-01-07T03:03:14Z
Comment #8 by github-bugzilla — 2017-01-16T23:26:02Z