[Issue 11206] static array can be implicitly built from items, when nested in aggregate
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Oct 9 09:02:31 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11206
monarchdodra at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |
--- Comment #2 from monarchdodra at gmail.com 2013-10-09 09:02:30 PDT ---
(In reply to comment #1)
> So, what?
>
> Basically you are complainig about:
>
> import std.stdio;
>
> struct AGG
> {
> int[1] t;
> double d;
> }
>
> void main()
> {
> AGG tarr2 = AGG(1);
> writeln(tarr2);
> }
>
> which prints AGG([1], nan).
...Unsure what you are trying to show? the "AGG(1)".
> AGG(1) is a struct literal which is valid in D.
I'm arguing that AGG should not be constructible taking a 1.
> Integer literal is a valid
> initializer for static array. Statement "AGG!S ts1 = AGG!S(1);" is rejected
> because (unfortunately) 1 is not convertible to struct.
Yes, integer is a valid initializer for a static array, and it is also a valid
initializer for a struct that holds an int.
However, 1 is not convertible to a struct, not is it convertible to a static
array. AGG(1) should not compile, because 1 is not convertible to
typeof(AGG.tupleof[0]);
What's happening is an implicit *construction* of a static array, in a context
where implicit construction is not allowed.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list