Bug 11955 – Aliased types not accepted in foreach over range of tuple

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-01-20T04:28:00Z
Last change time
2014-01-20T07:02:34Z
Keywords
pull, rejects-valid
Assigned to
yebblies
Creator
monarchdodra

Comments

Comment #0 by monarchdodra — 2014-01-20T04:28:24Z
Originally discovered while playing with JakobOvrum's enumrate: https://github.com/D-Programming-Language/phobos/pull/1866 I can reduce it to a simple range that returns a Tuple!(size_t, int). On win_32, this fails: //---- import std.typetuple, std.typecons; alias ET = Tuple!(size_t, int); struct S { enum empty = false; ET front() @property; void popFront(); } void main() { S s; //Or replace with "somthing.enumerate()" foreach(i, v; s) { pragma(msg, typeof(i).stringof); pragma(msg, typeof(v).stringof); } foreach(size_t i, int v; s) {} } //---- Compilation output: //---- uint int main.d(20): Error: cannot infer argument types //---- I only tested this on win_32, so I don't know how the other os's (linux), or versions (64) behave. While I don't think it is a hugely serious bug, it is also blocker in terms of portability.
Comment #1 by jakobovrum — 2014-01-20T04:34:43Z
(In reply to comment #0) > I only tested this on win_32, so I don't know how the other os's (linux), or > versions (64) behave. `size_t` is supposed to alias to `uint` for 32-bit targets, and `ulong` for 64-bit targets. See line 20 of object.di: --- alias typeof(int.sizeof) size_t; ---
Comment #2 by jakobovrum — 2014-01-20T04:36:17Z
(In reply to comment #1) > (In reply to comment #0) > > I only tested this on win_32, so I don't know how the other os's (linux), or > > versions (64) behave. > > `size_t` is supposed to alias to `uint` for 32-bit targets, and `ulong` for > 64-bit targets. > > See line 20 of object.di: > --- > alias typeof(int.sizeof) size_t; > --- Nevermind, I see what the bug is now.
Comment #3 by yebblies — 2014-01-20T06:04:02Z
struct T11955(T...) { T field; alias field this; } alias X11955 = uint; struct S11955 { enum empty = false; T11955!(uint, uint) front; void popFront() {} } void main() { foreach(X11955 i, v; S11955()) {} } The argument type 'X11955' has not had semantic run on it, so checking the implicit conversion from agg.front[0] to it fails. https://github.com/D-Programming-Language/dmd/pull/3127
Comment #4 by github-bugzilla — 2014-01-20T06:55:51Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/8562076728db18639cdeabab660b902af938758d Fix Issue 11955 - Aliased types not accepted in foreach over range of tuple Run semantic on the type before attempting implicit conversions. https://github.com/D-Programming-Language/dmd/commit/bc0c114df36b79e2bff2d5db66a019a51fbe7983 Merge pull request #3127 from yebblies/issue11955 Issue 11955 - Aliased types not accepted in foreach over range of tuple