digitalmars.D.bugs - [Issue 11857] New: `out` parameter breaks overload resolution
- d-bugmail puremagic.com (36/36) Jan 02 2014 https://d.puremagic.com/issues/show_bug.cgi?id=11857
- d-bugmail puremagic.com (13/13) Jan 02 2014 https://d.puremagic.com/issues/show_bug.cgi?id=11857
- d-bugmail puremagic.com (8/11) Jan 02 2014 https://d.puremagic.com/issues/show_bug.cgi?id=11857
- d-bugmail puremagic.com (8/8) Jan 11 2014 https://d.puremagic.com/issues/show_bug.cgi?id=11857
- d-bugmail puremagic.com (32/35) Jan 13 2014 https://d.puremagic.com/issues/show_bug.cgi?id=11857
- d-bugmail puremagic.com (11/11) Jan 13 2014 https://d.puremagic.com/issues/show_bug.cgi?id=11857
- d-bugmail puremagic.com (6/6) Jan 13 2014 https://d.puremagic.com/issues/show_bug.cgi?id=11857
https://d.puremagic.com/issues/show_bug.cgi?id=11857 Summary: `out` parameter breaks overload resolution Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: ice, rejects-valid Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: verylonglogin.reg gmail.com 17:00:51 MSK --- This code should compile: --- void f(int) { } void f(out int) { } void t(T)(T) { } void t(T)(out T) if(false) { } // line 4 void main() { const int n = 1; f(n); // line 9 t(n); // also causes ICE } --- main.d(9): Error: constant 1 is not an lvalue main.d(4): Error: cannot have const out parameter of type const(int) <access violation> --- Previously dmd just shown error. Now it also ICE-s with access violation in template case. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 02 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11857 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull Status|NEW |RESOLVED Resolution| |DUPLICATE https://github.com/D-Programming-Language/dmd/pull/3034 *** This issue has been marked as a duplicate of issue 11822 *** -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 02 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11857 11:07:39 MSK ---https://github.com/D-Programming-Language/dmd/pull/3034 *** This issue has been marked as a duplicate of issue 11822 ***If it really is change issue 11822 title appropriately as this issue has nothing to do with `-de` switch. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 02 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11857 01:53:22 MSK --- So do I understand correctly ICE part of the issue is considered a duplicate of issue 11822 and "This code should compile" part is considered WONTFIX? If so, where is the documentation claiming such code incorrect? -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 11 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11857So do I understand correctly ICE part of the issue is considered a duplicate of issue 11822 and "This code should compile" part is considered WONTFIX? If so, where is the documentation claiming such code incorrect?In short, yes. Even `const int n = 1` is interpreted in compile time, `n` is a local variable that has runtime storage on stack. Therefore, expression `n` makes lvalue, then preferentially matches to `out` parameter. This behavior is intended to reduce confusion at the situation that mixing constant-folding and compile-time/runtime evaluation. Example: void f( immutable int n); void f(ref immutable int n); // accepts only lvalue void foo(int x) { immutable int n = x; // n is evaluated in runtime (when foo is called) f(n); // n matches to ref version } void bar(int x) { immutable int n = 1; // n can be interpreted at compile time, // but still allocated on stack and initialized in runtime. f(n); // n still matches to ref version } D is designed to provide consistent overload resolution result for f(n) in both foo and bar. In other words, variable evaluation and its ref-ness is strictly separated from the CTFE/constant-folding. Conflating them would make hard to understand overload resolution result. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 13 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11857 18:28:07 MSK --- Thanks, but this doesn't answer the question. Probably I should be more precise: 1. Why `ref` works and `out` doesn't work (in `ref` case the only matching non-ref overload is selected)? 2. Why disabled by `if(false)` constraint overload breaks overload resolution? -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 13 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11857 18:57:38 MSK --- I segregated Issue 11915 and Issue 11916 for discussion. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 13 2014