[Issue 5185] Recursive template expansion error in class method

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Dec 10 00:11:34 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=5185



--- Comment #3 from github-bugzilla at puremagic.com 2013-12-10 00:11:31 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/a29d09aee89885f59d413b1451e1ec843e1e4985
fix Issue 5185 - Recursive template expansion error in class method

As the test casein 5185, `checkRecursiveExpansion` would prevent legitimate
template instantiation.

If a template instance depends on the definition of itself, it is a true
"recursion". But, a declaration sometimes can depend on the declaration itself.

For example, a class can have same class reference in its field (class C { C
field; }). All of class types are references in D, so its type size (==
definition) is equal to pointer size. So, even if self class type is used in
its declaration, it won't cause definition recursion, because compiler can
treat the class definition as opaque during semantic analysis of the
declaration.

Returning to the template instance case, compiler cannot treat instance
definition as opaque. However, to put it another way, compiler cannot detect
the "true recursion" until instantiating the template. In other words, we
cannot detect template recursion by merely seeing template arguments.

Therefore, I think the check is merely unnecessary. We have to rely on the nest
level detector of template instantiations, and circular chain detector of
`tinst` during semantic3.

https://github.com/D-Programming-Language/dmd/commit/e542c5a746fbe72a984444aab2105ac5dd660ace
Merge pull request #2940 from 9rnsr/fix5185

Issue 5185 - Recursive template expansion error in class method

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list