[Issue 13954] New: (D1 only) Compiler allows implementing floating point return method with a real return type
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Jan 8 06:17:43 PST 2015
https://issues.dlang.org/show_bug.cgi?id=13954
Issue ID: 13954
Summary: (D1 only) Compiler allows implementing floating point
return method with a real return type
Product: D
Version: D1
Hardware: x86_64
OS: Linux
Status: NEW
Keywords: industry
Severity: normal
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: andrej.mitrovich at gmail.com
-----
class A
{
abstract public float get();
}
class C : A
{
public real get() { return 0; }
}
void main ( )
{
A a = new C;
assert(a.get() == 0);
}
-----
This assertion fails.
Note that the above should not compile. The equivalent D2 code is caught at
compile-time:
test.d(15): Error: cannot create instance of abstract class C
test.d(15): function 'float get()' is not implemented
--
More information about the Digitalmars-d-bugs
mailing list