D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7832 - opAssign does not get used for function parameters with a default value
Summary: opAssign does not get used for function parameters with a default value
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P2 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-05 15:35 UTC by William Moore
Modified: 2012-05-07 15:30 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description William Moore 2012-04-05 15:35:30 UTC
So if I define an opAssign for a struct with void* as the parameter like so:

struct test {void opAssign(void*mynull) {}}

It works great when used in a normal assignment like so:

void main () {
        test t = null; // compiles just fine
}

but refuses to compile for function parameters with default values of null like so:

void tfunc(test t = null) {} // nope nope nope nope


This occurs in 2.058.
Comment 1 William Moore 2012-04-20 05:51:42 UTC
It was late when I submitted this, so I wasn't thinking about what was actually going on here.  The null assignment as a default parameter is treated as though it were passed as an argument which would require some way to cast implicitly....  So given that, this really becomes a feature request for implicit casting support.