[Issue 10846] Allow defining functions in enum declarations

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Aug 18 15:15:55 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10846



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-08-18 15:15:55 PDT ---
(In reply to comment #1)
> Another alternative is to relax the function hijacking protection a little bit. 
> 
> If function "foo" in module "a" takes a user-defined type, and function "foo"
> in module "b" takes another user-defined type, where the types are structures
> and have no subtyping relation to one another, then I think it's safe to allow
> these two functions to overload against one another without requiring the user
> to manually merge the overload set.
> 
> Wouldn't this be safe?

Here's what I don't quite understand. This test-case fails:

-----
module a;
import b;
struct A { }

void test(A a) { }

void main()
{
    B b;
    b.test();
}
-----

-----
module b;
struct B { }
void test(B b) { }
-----

$ dmd -c a.d
> a.d(10): Error: function a.test (A a) is not callable using argument types (B)

But this test-case works:

-----
module a;
struct A { }
void test(A a) { }
-----

-----
module b;
struct B { }
void test(B b) { }
-----

-----
module main;
import a;
import b;
void main()
{
    B b;
    b.test();
}
-----

$ dmd -c main.d
>

Shouldn't then both test-cases either fail or succeed?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list