Bug 3682 – Regression(2.038) is expression fails to match types

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-01-06T14:54:00Z
Last change time
2015-06-09T01:27:14Z
Keywords
rejects-valid
Assigned to
nobody
Creator
snake.scaly

Comments

Comment #0 by snake.scaly — 2010-01-06T14:54:38Z
contents of "a.d": import std.typecons; contents of "b.d": import std.typecons; alias Tuple!(int) tint; compile like this: dmd -unittest a.d b.d error message: C:\opt\dmd.2.038\windows\bin\..\..\src\phobos\std\typecons.d(424): Error: static assert (is(Tuple!(string,float) == Tuple!(string,float))) is false C:\opt\dmd.2.038\windows\bin\..\..\src\phobos\std\typecons.d(413): instantiated from here: Tuple!(string,float) C:\opt\dmd.2.038\windows\bin\..\..\src\phobos\std\typecons.d(423): instantiated from here: slice!(1,3) C:\opt\dmd.2.038\windows\bin\..\..\src\phobos\std\typecons.d(420): instantiated from here: Tuple!(int,string,float,double) b.d(2): instantiated from here: Tuple!(int) This is a regression from 2.037.
Comment #1 by aifgi90 — 2010-01-24T09:18:05Z
If compiled like "dmd -unittest b.d a.d" or "dmd a.d b.d", it compiles fine, but fails with "dmd -unittest a.d b.d"
Comment #2 by r.sagitario — 2010-02-14T07:24:26Z
I've debugged this issue a bit: it seems to have to do with the unittest inside struct Tuple(T...) auto inferring the return type of Tuple.slice(). This triggers a recursive semantic analysis, which results in the template instance not being resolved (the type stays qualified as TemplateInstance). A simple workaround is moving the unittest out of the template definition of Tuple.
Comment #3 by clugdbug — 2010-08-24T12:39:36Z
Reduced testcase shows that it doesn't require -unittest, and it is D2-only. --- a3682.d-------------- struct Tuple(Types...) { Tuple!(Types[0..1]) slice()() { Tuple!(Types[0..1]) x; return x; } void fail() { Tuple!(float, double, int) a; auto s = a.slice(); static assert(is(typeof(s) == Tuple!(float))); } } ---- b3682.d-------------- import a3682; alias Tuple!(int) tint; -------------------------- > dmd a3682 b3682 a3682.d(14): Error: static assert (is(Tuple!(float) == Tuple!(float))) is false a3682.d(4): instantiated from here: Tuple!(float) a3682.d(13): instantiated from here: slice!() a3682.d(12): instantiated from here: Tuple!(float,double,int) b3682.d(2): instantiated from here: Tuple!(int)
Comment #4 by clugdbug — 2010-09-29T00:27:01Z
Caused by svn 318, which was fixing bug 282 "Bizarre circular import nested name invisibility issue". Regression bug 4543 was introduced at the same time.
Comment #5 by ibuclaw — 2011-03-24T12:08:10Z
The (new?) error message I get from the reduced testcase is: a3682.d(12): Error: cannot implicitly convert expression (a.slice()) of type Tuple!(float) to Tuple!(float)
Comment #6 by bugzilla — 2012-03-02T12:51:49Z
It works with D2 2.059 head
Comment #7 by clugdbug — 2012-03-08T02:01:32Z
The test case in comment 3 still fails for me with 2.059 head. Note that the compilation order is important: dmd a3682.d b3682.d fails, but dmd b3682.d a3682.d works.
Comment #8 by github-bugzilla — 2012-03-09T14:25:02Z
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/38deee3916b4158b858c6e03dd5aac8dea377f19 fix Issue 3682 - Regression(2.038) is expression fails to match types
Comment #9 by github-bugzilla — 2012-03-09T14:27:05Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/804dc3b28752673ed402c5ec0ad9aa3cacf4f374 fix Issue 3682 - Regression(2.038) is expression fails to match types
Comment #10 by bugzilla — 2012-03-09T14:27:45Z
This one took many hours to track down :-)
Comment #11 by github-bugzilla — 2013-01-03T00:42:41Z