Thread overview | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
December 14, 2011 [Issue 7110] New: static opSlice & opIndex functions don't work as template arguments | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=7110 Summary: static opSlice & opIndex functions don't work as template arguments Product: D Version: D1 & D2 Platform: Other OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: verylonglogin.reg@gmail.com --- Comment #0 from Denis <verylonglogin.reg@gmail.com> 2011-12-14 16:29:58 MSK --- --- struct S { } struct Call { static S opSlice() { return S(); } static S opIndex(size_t) { return S(); } } template Template(Args...) { static assert(is(typeof(Args[0]) == S)); } alias Template!(S()) A0; // passes alias Template!(Call.opSlice()) A1; // passes alias Template!(Call.opIndex(0)) A2; // passes alias Template!(Call[]) A3; // failes alias Template!(Call[0]) A4; // failes --- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 14, 2011 [Issue 7110] static opSlice & opIndex functions don't work as template arguments | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis | http://d.puremagic.com/issues/show_bug.cgi?id=7110 Robert Clipsham <robert@octarineparrot.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |robert@octarineparrot.com --- Comment #1 from Robert Clipsham <robert@octarineparrot.com> 2011-12-14 13:54:49 GMT --- I believe this is invalid - here Call[] is a dynamic array of Call, and Call[0] is a static array of Call, length zero. You can work around this using: ---- alias Template!({ return Call[]; }()) A3; alias Template!({ return Call[0]; }()) A4; ---- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 14, 2011 [Issue 7110] static opSlice & opIndex functions don't work as template arguments | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis | http://d.puremagic.com/issues/show_bug.cgi?id=7110 Denis <verylonglogin.reg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID --- Comment #2 from Denis <verylonglogin.reg@gmail.com> 2011-12-14 17:05:10 MSK --- Thanks! I'm completely wrong here. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 14, 2011 [Issue 7110] opSlice() & opIndex functions works unstable as template arguments | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis | http://d.puremagic.com/issues/show_bug.cgi?id=7110 Denis <verylonglogin.reg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|INVALID | Summary|static opSlice & opIndex |opSlice() & opIndex |functions don't work as |functions works unstable as |template arguments |template arguments --- Comment #3 from Denis <verylonglogin.reg@gmail.com> 2011-12-14 18:06:17 MSK --- And an easier workaround: --- alias Template!((Call[])) A3; // passes alias Template!((Call[0])) A4; // passes --- But isn't it strange? Looks like this workaround is a bug. It leads to things like this: --- struct S { int opSlice(int, int) const { return 0; } int opSlice() const { return 0; } int opIndex(int, int) const { return 0; } int opIndex(int) const { return 0; } } enum e = S(); template T(alias a) { } // or T(a...) alias T!( S ) T0; // passes alias T!((S)) T1; // passes alias T!( S()[0..0] ) A0; // passes alias T!( (e[0..0]) ) A1; // passes alias T!( e[0..0] ) A2; // passes alias T!( S()[0, 0] ) B0; // passes alias T!( (e[0, 0]) ) B1; // passes alias T!( e[0, 0] ) B2; // passes alias T!( S()[] ) C0; // passes alias T!( (e[]) ) C1; // passes alias T!( e[] ) C2; // fails: e is used as a type alias T!( S()[0] ) D0; // passes alias T!( (e[0]) ) D1; // passes alias T!( e[0] ) D2; // fails: e must be an array or pointer type, not S --- And the last error message looks wrong. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 04, 2012 [Issue 7110] opSlice() & opIndex functions works unstable as template arguments | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis | http://d.puremagic.com/issues/show_bug.cgi?id=7110 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull, rejects-valid --- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> 2012-03-04 05:00:31 PST --- https://github.com/D-Programming-Language/dmd/pull/784 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 10, 2012 [Issue 7110] opSlice() & opIndex functions works unstable as template arguments | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis | http://d.puremagic.com/issues/show_bug.cgi?id=7110 --- Comment #5 from github-bugzilla@puremagic.com 2012-03-09 22:22:48 PST --- Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/28edc2597a9f1e802e3a2e18353b3038a5307ac5 Merge pull request #784 from 9rnsr/fix7110 Issue 7110 - opSlice() & opIndex functions works unstable as template arguments -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 10, 2012 [Issue 7110] opSlice() & opIndex functions works unstable as template arguments | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis | http://d.puremagic.com/issues/show_bug.cgi?id=7110 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED CC| |bugzilla@digitalmars.com Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation