Thread overview | |||||
---|---|---|---|---|---|
|
April 27, 2011 [Issue 5899] New: auto-return function cannot match 'null' with reference type. | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=5899 Summary: auto-return function cannot match 'null' with reference type. Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: rejects-valid Severity: minor Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: kennytm@gmail.com --- Comment #0 from kennytm@gmail.com 2011-04-27 08:46:39 PDT --- Test code 1: --------------------------- class K {} auto f(bool b) { if (b) return new K; else return null; } --------------------------- x.d(6): Error: mismatched function return type inference of void* and x.K --------------------------- Test code 2: --------------------------- auto f(bool b) { if (b) return new int; else return null; } --------------------------- x.d(5): Error: mismatched function return type inference of void* and int* --------------------------- DMD should know that 'null' is a valid value for any reference types. A workaround is to give an exact type, e.g. --------------------------- auto f(bool b) { if (b) return new int; // or new K; else { typeof(return) n = null; return n; } } --------------------------- but this should not be necessary. (Perhaps the D spec should give a specific type e.g. 'nullptr_t' for 'null'?) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 27, 2011 [Issue 5899] auto-return function cannot match 'null' with reference type. | ||||
---|---|---|---|---|
| ||||
Posted in reply to kennytm@gmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=5899 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch --- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2011-10-27 05:08:39 PDT --- https://github.com/D-Programming-Language/dmd/pull/476 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 25, 2011 [Issue 5899] auto-return function cannot match 'null' with reference type. | ||||
---|---|---|---|---|
| ||||
Posted in reply to kennytm@gmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=5899 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla@digitalmars.com Resolution| |FIXED --- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2011-11-25 00:29:00 PST --- https://github.com/D-Programming-Language/dmd/commit/31a3e406938cef17c8c6354ac5de70ad07707027 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation