March 06, 2009 [Issue 2713] New: Error resolving types with ? : and const | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=2713 Summary: Error resolving types with ? : and const Product: D Version: 2.025 Platform: PC URL: http://www.digitalmars.com/webnews/newsgroups.php?art_gr oup=digitalmars.D&article_id=85423 OS/Version: All Status: NEW Keywords: rejects-valid Severity: minor Priority: P3 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: zildjohn01@gmail.com The following fails to compile: bool flag() { bool left, right; return true ? cast(const bool)left : cast(bool)right; } with the error "cannot implicitly convert expression (cast(int)left) of type int to bool". It seems to happen whenever the left and right sides differ in const-ness or invariant-ness. This becomes an issue when trying to write const-correct class functions which return bool, for example: class C { private int mask; private bool readyYet() const {return true;} public bool ExtractStateBit() const { return readyYet() ? (mask & 1) : false; } } -- |
June 07, 2010 [Issue 2713] Error resolving types with ? : and const | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2713 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |clugdbug@yahoo.com.au Resolution| |FIXED --- Comment #1 from Don <clugdbug@yahoo.com.au> 2010-06-07 01:51:10 PDT --- Fixed DMD2.031. -- 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