[Issue 6969] Forward reference on template class triangle
http://d.puremagic.com/issues/show_bug.cgi?id=6969 --- Comment #10 from github-bugzi...@puremagic.com 2012-11-13 12:27:37 PST --- Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/75b0fafc74eda2fed816415e31dcbfde8283077d fix Issue 6969 - Forward reference on template class triangle https://github.com/D-Programming-Language/dmd/commit/c34c5fb0e67f7c48bb683ef409378fde6db33088 Merge pull request #1280 from 9rnsr/fix8990 Issue 6969 8990 - Forward reference error between three template instantiations -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 6969] Forward reference on template class triangle
http://d.puremagic.com/issues/show_bug.cgi?id=6969 Walter Bright bugzi...@digitalmars.com changed: What|Removed |Added Status|NEW |RESOLVED Resolution||FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 6969] Forward reference on template class triangle
http://d.puremagic.com/issues/show_bug.cgi?id=6969 Rob T al...@ucora.com changed: What|Removed |Added CC||al...@ucora.com --- Comment #7 from Rob T al...@ucora.com 2012-11-10 00:39:04 PST --- (In reply to comment #6) This works: class A { alias C C1; } class B { alias A A1; } class C : B { } It works because there are no actual circular references, and that's because the class alias are in reality pointers, and pointers are known data types irrespective of what they may represent (the definition expansion should stop at the pointer). The compiler is certainly able to determine what the pointers represent for dereferencing purposes as the class structures and contents are 100% knowable. Note that if you convert the pointers to represent structs, ie change class to struct, and fix up struct C to contain struct B due to a lack of inheritance, it will no longer work, which is to be expected. To make the struct version work again, you simply change the contained B to a pointer. // this fails, and it should fail, so we're good. struct A() { C!() C1; } struct B { A!() A1; } struct C() { B s; } // this works, and it should work, so we're good. struct A() { C!() C1; } struct B { A!() A1; } struct C() { B* s; // changed to pointer } The problem at hand is definitely a bug from what I see. --rt -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 6969] Forward reference on template class triangle
http://d.puremagic.com/issues/show_bug.cgi?id=6969 --- Comment #8 from Rob T al...@ucora.com 2012-11-10 01:34:57 PST --- (In reply to comment #7) (In reply to comment #6) I get weird behavior if I put in only the alias definitions. This stuct version compiles, and it probably should because sA and sB are empty with no circular referencing. struct sA() { alias sC!() sC1; } struct sB { alias sA!() sA1; } struct sC() { sB s; } But adding sA1 into sB will not compile, but I think it should compile because sA is empty and there's no circular reference back to sC. struct sA() { alias sC!() sC1; } struct sB { alias sA!() sA1; sA1 a; } struct sC() { sB b; } In fact it does compile in the non-template version as expected. struct sA { alias sC sC1; } struct sB { alias sA sA1; sA1 a; } struct sC() { sB b; } Finally, closing the loop will not compile as expected struct sA { alias sC sC1; sC1 c; // bang, we're dead. } struct sB { alias sA sA1; sA1 a; } struct sC() { sB b; } Templates and non-templates are being evaluated inconsistently, so there's definitely a bug in there somewhere. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 6969] Forward reference on template class triangle
http://d.puremagic.com/issues/show_bug.cgi?id=6969 Nick Sabalausky cbkbbej...@mailinator.com changed: What|Removed |Added Severity|blocker |critical -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 6969] Forward reference on template class triangle
http://d.puremagic.com/issues/show_bug.cgi?id=6969 --- Comment #6 from Nick Sabalausky cbkbbej...@mailinator.com 2012-04-29 21:23:36 PDT --- This works: class A { alias C C1; } class B { alias A A1; } class C : B { } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 6969] Forward reference on template class triangle
http://d.puremagic.com/issues/show_bug.cgi?id=6969 Walter Bright bugzi...@digitalmars.com changed: What|Removed |Added CC||bugzi...@digitalmars.com --- Comment #5 from Walter Bright bugzi...@digitalmars.com 2012-04-28 02:04:29 PDT --- It's not really a forward reference, it's a circular one. B is defined in terms of itself. I'm not sure how this could ever work. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 6969] Forward reference on template class triangle
http://d.puremagic.com/issues/show_bug.cgi?id=6969 Nick Sabalausky cbkbbej...@mailinator.com changed: What|Removed |Added Severity|critical|blocker --- Comment #4 from Nick Sabalausky cbkbbej...@mailinator.com 2012-04-23 17:58:53 PDT --- Commenting out that call to semantic2 no longer fixes the problem in latest DMD in Git (and Phobos fails to rebuild with the change). So I've got no clue. But this is still blocking me from some major refactoring I need to do. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 6969] Forward reference on template class triangle
http://d.puremagic.com/issues/show_bug.cgi?id=6969 --- Comment #2 from Nick Sabalausky cbkbbej...@mailinator.com 2011-12-06 16:57:34 PST --- I'm not very familiar with DMD's internals wrt semantics, but from what I can tell so far, the problem may have to do with a certain section near the end of TemplateInstance::semantic(Scope *sc, Expressions *fargs): ... /* The problem is when to parse the initializer for a variable. * Perhaps VarDeclaration::semantic() should do it like it does * for initializers inside a function. */ //if (sc-parent-isFuncDeclaration()) /* BUG 782: this has problems if the classes this depends on * are forward referenced. Find a way to defer semantic() * on this template. */ semantic2(sc2); ... That call to semantic2 is the call stack when the has forward references error is thrown. Note that this occurs before tryMain() reaches semantic2. Do to my inexperience with DMD's internals, I have no idea if there's some reason that call to semantic2 is supposed to be there. And I don't understand what those comments are trying to say. But if I comment out that semantic2 call, the test case passes. However, I don't know whether that breaks anything else. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 6969] Forward reference on template class triangle
http://d.puremagic.com/issues/show_bug.cgi?id=6969 --- Comment #3 from Nick Sabalausky cbkbbej...@mailinator.com 2011-12-06 16:59:05 PST --- *Ahem*: That call to semantic2 is *IN* the call stack... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 6969] Forward reference on template class triangle
http://d.puremagic.com/issues/show_bug.cgi?id=6969 Nick Sabalausky cbkbbej...@mailinator.com changed: What|Removed |Added Severity|normal |critical --- Comment #1 from Nick Sabalausky cbkbbej...@mailinator.com 2011-11-21 13:50:16 PST --- Severity - critical This is blocking a major refactoring in my project. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---