Bug 3552 – ICE(mtype.c): declaring a variable called 'AssociativeArray' then using an AA.

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2009-11-25T07:35:00Z
Last change time
2015-06-09T01:27:03Z
Keywords
ice-on-valid-code, patch
Assigned to
nobody
Creator
justin.greenwood

Attachments

IDFilenameSummaryContent-TypeSize
518testAssociativeArrayFails.dThe simple example that shows the error.text/plain1329
519testAssociativeArrayWorks.dThe simple example that doesn't fail because I removed the use of the variant module.text/plain1259

Comments

Comment #0 by justin.greenwood — 2009-11-25T07:35:36Z
Created attachment 518 The simple example that shows the error. I have attached two files, both simple code illustrating the error I've run into. In the testAssociativeArrayFails.d file, there is a foreach block that iterates through an associative array. If that foreach block is removed, the file compiles fine. The error is not really meaningful and I imagine the assertion errors in the compiler should not happen. To help show what is causing the bug, I wrote the same sample class without using a Variant internally in my class and everything works fantastically. I put a shitload of time trying to figure out the error in a much more complicated program - this error just started when I upgraded to the newest version of DMD 2.x. I hope you can make use of my example code. When I run the attached files, this is the output: ------------------------------------------------------------------------------- F:\projects\home\home-svn\d\www>c:\d\dmd2\windows\bin\dmd.exe ".\src\testAssocia tiveArrayFails.d" -of.\bin\testAssociativeArrayFails.exe .\src\testAssociativeArrayFails.d(14): Error: template instance AssociativeArray is not a template declaration, it is a overloadset Assertion failure: 'impl' on line 3351 in file 'mtype.c' abnormal program termination F:\projects\home\home-svn\d\www>.\bin\testAssociativeArrayFails.exe '.\bin\testAssociativeArrayFails.exe' is not recognized as an internal or extern al command, operable program or batch file. F:\projects\home\home-svn\d\www>c:\d\dmd2\windows\bin\dmd.exe ".\src\testAssocia tiveArrayWorks.d" -of.\bin\testAssociativeArrayWorks.exe F:\projects\home\home-svn\d\www>.\bin\testAssociativeArrayWorks.exe ** Associative Array using Classes without variants ** true = 12.32 12 = 14
Comment #1 by justin.greenwood — 2009-11-25T07:36:28Z
Created attachment 519 The simple example that doesn't fail because I removed the use of the variant module.
Comment #2 by clugdbug — 2009-11-25T08:08:50Z
Reduced test case shows it's very silly. Obviously it's a name lookup problem. void main() { int AssociativeArray; int[int] foo; foreach (x; foo) { } }
Comment #3 by justin.greenwood — 2009-11-25T19:24:56Z
FYI - For anyone that needs to work around this temporarily, just copy the std.variant module to a different module location. Change the module declaration at the top to match the new location and replace the text "AssociativeArray" with another name (be careful not to replace "isAssociativeArray"). Worked for me - at least until a new build is released.
Comment #4 by clugdbug — 2009-12-29T00:58:15Z
PATCH: Instead of trying to instantiate AssociativeArray, do .AssociativeArray instead. Index: mtype.c =================================================================== --- mtype.c (revision 317) +++ mtype.c (working copy) @@ -3854,13 +3854,14 @@ * But the instantiation can fail if it is a template specialization field * which has Tident's instead of real types. */ - TemplateInstance *ti = new TemplateInstance(loc, Id::AssociativeArray); + Objects *tiargs = new Objects(); tiargs->push(index); tiargs->push(next); - ti->tiargs = tiargs; + DotTemplateInstanceExp *dti = new DotTemplateInstanceExp(loc, new IdentifierExp(loc, Id::empty), Id::AssociativeArray, tiargs); - ti->semantic(sc); + dti->semantic(sc); + TemplateInstance *ti = dti->ti; ti->semantic2(sc); ti->semantic3(sc); impl = ti->toAlias()->isStructDeclaration();
Comment #5 by clugdbug — 2010-01-08T22:01:29Z
*** Issue 3692 has been marked as a duplicate of this issue. ***
Comment #6 by bugzilla — 2010-01-23T02:51:04Z
Changeset 352
Comment #7 by bugzilla — 2010-01-30T22:45:16Z
fixed dmd 2.040