Bug 6367 – Multi-assignment for typetuples is bad

Status
REOPENED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-07-23T05:28:42Z
Last change time
2024-12-13T17:55:57Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
bearophile_hugs
Moved to GitHub: dmd#18359 →

Comments

Comment #0 by bearophile_hugs — 2011-07-23T05:28:42Z
This is a spinoff of issue 6365 This program compiles and runs with no errors (it doesn't assert), DMD 2.054: import std.typetuple; void main() { TypeTuple!(int, int) f = 10; assert(f[0] == 10); assert(f[1] == 10); } The idea of carring this broken TypeTuple semantics over to Tuples too is icky. I instead suggest to turn this into a compile-time error.
Comment #1 by monarchdodra — 2014-03-31T07:25:30Z
Is this an actually documented feature? Does the spec say it works, or does it just happen to look that way...?
Comment #2 by k.hara.pg — 2014-03-31T19:14:06Z
(In reply to comment #1) > Is this an actually documented feature? > > Does the spec say it works, or does it just happen to look that way...? It's properly documented. http://dlang.org/tuple > Tuple Declarations > > A variable declared with a TypeTuple becomes an ExpressionTuple: > > alias TL = Tuple!(int, long); > > void foo(TL tl) > { > writeln(tl, tl[1]); > } > > foo(1, 6L); // prints 166
Comment #3 by monarchdodra — 2014-03-31T23:19:14Z
(In reply to comment #2) > (In reply to comment #1) > > Is this an actually documented feature? > > > > Does the spec say it works, or does it just happen to look that way...? > > It's properly documented. > > http://dlang.org/tuple That page makes no mention of initialization. It merely states that: "A variable declared with a TypeTuple becomes an ExpressionTuple" I'm asking about said items initialization scheme: //---- import std.typetuple; void main() { alias T = TypeTuple; T!(int, int) t1 = T!(1, 2); // OK T!(int, int) t2 = 1; // OK? } //---- Further, std.typecons.Tuple does not support such an initialization scheme.
Comment #4 by bearophile_hugs — 2014-04-01T01:35:23Z
Reopened because I see no valid reason to close this yet. And even if the specs say that typetuples should behave like this, I'll reopen this as enhancement (because in that case I think it's a spec bug).
Comment #5 by robert.schadek — 2024-12-13T17:55:57Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18359 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB