Thread overview | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
March 02, 2014 [Issue 12287] New: infinite loop on std.traits.moduleName on templated struct member | ||||
---|---|---|---|---|
| ||||
https://d.puremagic.com/issues/show_bug.cgi?id=12287 Summary: infinite loop on std.traits.moduleName on templated struct member Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: major Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: oivind.loe@gmail.com --- Comment #0 from Øivind <oivind.loe@gmail.com> 2014-03-02 12:55:35 PST --- Compile of the following code never completes. If the struct is not a template, the behavior is as expected. Don't know if this is a DMD or Phobos issue. Running on 2.065.0 import std.stdio; import std.traits; struct X(T) { T i; } void main(){ writeln(moduleName!((X!int).i)); } -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 02, 2014 [Issue 12287] infinite loop on std.traits.moduleName on templated struct member | ||||
---|---|---|---|---|
| ||||
Posted in reply to Øivind | https://d.puremagic.com/issues/show_bug.cgi?id=12287 Vladimir Panteleev <thecybershadow@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |thecybershadow@gmail.com --- Comment #1 from Vladimir Panteleev <thecybershadow@gmail.com> 2014-03-02 23:20:31 EET --- It looks like the underlying problem is that the parent of a template instance is the template instance itself. Reduced: struct X(T) { } alias Xi = X!int; static assert(!__traits(isSame, Xi, __traits(parent, Xi))); -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 02, 2014 [Issue 12287] infinite loop on std.traits.moduleName on templated struct member | ||||
---|---|---|---|---|
| ||||
Posted in reply to Øivind | https://d.puremagic.com/issues/show_bug.cgi?id=12287 --- Comment #2 from Vladimir Panteleev <thecybershadow@gmail.com> 2014-03-02 23:42:03 EET --- I think this only applies to eponymous templates. The parent of the member is the struct declaration, the parent of which is the template instance. But when referring to the template instance of an eponymous template, it is "converted" to the symbol it wraps (the struct declaration), so it never exits the cycle. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 02, 2014 [Issue 12287] infinite loop on std.traits.moduleName on templated struct member | ||||
---|---|---|---|---|
| ||||
Posted in reply to Øivind | https://d.puremagic.com/issues/show_bug.cgi?id=12287 Vladimir Panteleev <thecybershadow@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #3 from Vladimir Panteleev <thecybershadow@gmail.com> 2014-03-02 23:58:21 EET --- https://github.com/D-Programming-Language/dmd/pull/3346 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 03, 2014 [Issue 12287] infinite loop on std.traits.moduleName on templated struct member | ||||
---|---|---|---|---|
| ||||
Posted in reply to Øivind | https://d.puremagic.com/issues/show_bug.cgi?id=12287 --- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> 2014-03-02 18:19:10 PST --- (In reply to comment #2) > I think this only applies to eponymous templates. The parent of the member is the struct declaration, the parent of which is the template instance. But when referring to the template instance of an eponymous template, it is "converted" to the symbol it wraps (the struct declaration), so it never exits the cycle. No, this is a Phobos bug. I think it's not good to add a special case in __traits(parent) for eponymous templates. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 03, 2014 [Issue 12287] infinite loop on std.traits.moduleName on templated struct member | ||||
---|---|---|---|---|
| ||||
Posted in reply to Øivind | https://d.puremagic.com/issues/show_bug.cgi?id=12287 --- Comment #5 from Vladimir Panteleev <thecybershadow@gmail.com> 2014-03-03 04:21:23 EET --- (In reply to comment #4) > No, this is a Phobos bug. I think it's not good to add a special case in __traits(parent) for eponymous templates. How can you fix it in Phobos, if it is not possible to get the parent of an eponymous template? -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 03, 2014 [Issue 12287] infinite loop on std.traits.moduleName on templated struct member | ||||
---|---|---|---|---|
| ||||
Posted in reply to Øivind | https://d.puremagic.com/issues/show_bug.cgi?id=12287 --- Comment #6 from Kenji Hara <k.hara.pg@gmail.com> 2014-03-02 18:33:03 PST --- (In reply to comment #5) > (In reply to comment #4) > > No, this is a Phobos bug. I think it's not good to add a special case in __traits(parent) for eponymous templates. > > How can you fix it in Phobos, if it is not possible to get the parent of an eponymous template? https://github.com/D-Programming-Language/phobos/pull/1978 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 03, 2014 [Issue 12287] infinite loop on std.traits.moduleName on templated struct member | ||||
---|---|---|---|---|
| ||||
Posted in reply to Øivind | https://d.puremagic.com/issues/show_bug.cgi?id=12287 --- Comment #7 from Vladimir Panteleev <thecybershadow@gmail.com> 2014-03-03 04:34:43 EET --- OK, so you pattern-match the template. But I don't think this is a good solution, because any recursive use of __traits(parent) will need to take care of this special case. It goes against the principle of least surprise. What are your arguments against a compiler change? -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 03, 2014 [Issue 12287] infinite loop on std.traits.moduleName on templated struct member | ||||
---|---|---|---|---|
| ||||
Posted in reply to Øivind | https://d.puremagic.com/issues/show_bug.cgi?id=12287 --- Comment #8 from Kenji Hara <k.hara.pg@gmail.com> 2014-03-02 18:46:53 PST --- (In reply to comment #7) > OK, so you pattern-match the template. > > But I don't think this is a good solution, because any recursive use of __traits(parent) will need to take care of this special case. It goes against the principle of least surprise. > > What are your arguments against a compiler change? Because your compiler change will make some part of the internal structure of the template instantiation invisible. Any compiler-side special handlings are unavoidable behavior for the all language users. So I'm afraid that your change might become harmful blocker for some users. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 03, 2014 [Issue 12287] infinite loop on std.traits.moduleName on templated struct member | ||||
---|---|---|---|---|
| ||||
Posted in reply to Øivind | https://d.puremagic.com/issues/show_bug.cgi?id=12287 --- Comment #9 from Vladimir Panteleev <thecybershadow@gmail.com> 2014-03-03 04:49:01 EET --- (In reply to comment #8) > Because your compiler change will make some part of the internal structure of the template instantiation invisible. I don't understand. Why? Before my patch: __traits(parent, X!foo) is the same symbol as X!foo. It did not reveal any internal structure at all, the result was completely useless. After my patch, it produces the result that a casual user may expect from an eponymous template, especially when declared like struct S(Args) {...} -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation