[Issue 1604] New: Non-final method on final struct is too restrictive
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Oct 20 13:31:41 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1604
Summary: Non-final method on final struct is too restrictive
Product: D
Version: 2.007
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: andrei at metalanguage.com
Currently, code like:
foreach (e; array)
{
e.function();
}
fails with the message "Error: cannot call mutable method on final struct" if
function is not const. But function can modify data indirectly referenced by e,
so the restriction is not justified.
Suggested fix: lift that restriction for now. In the future, if function's
source is available, issue an error if and only if function does not use the
object as an rvalue.
--
More information about the Digitalmars-d-bugs
mailing list