August 08, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3231





--- Comment #10 from Cristi Vlasceanu <cristian@zerobugs.org>  2009-08-08 13:25:53 PDT ---
(In reply to comment #9)
> (In reply to comment #5)
> > I think that marking the bug as invalid because of a limitation in the implementation is ridiculous.
> 
> AIUI this isn't a limitation in the implementation, but a characteristic of how D is designed.
> 
> > The fix (which I am applying to the my source tree at http://dnet.codeplex.com/) is very simple: continue the look up in enclosing scope.
> 
> Better beware of hijacking vulnerabilities.

This is possibly valid, do you have an example that drives your point?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 08, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3231





--- Comment #11 from Stewart Gordon <smjg@iname.com>  2009-08-08 16:07:09 PDT ---
(In reply to comment #10)
> (In reply to comment #9)
> > Better beware of hijacking vulnerabilities.
> 
> This is possibly valid, do you have an example that drives your point?

I'm not sure if there are any in this particular instance, but it's something to be careful of whenever you try to resolve a symbol to a different scope depending on how it's being used.

It may be the case that the worst that can happen here is that the class-level function conflicts with an opCall on the module-level class.  While no call of the form Bar(...) is happening here, I can see it getting confusing if one does occur....

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 08, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3231





--- Comment #12 from Tim M <tim.matthews7@gmail.com>  2009-08-08 16:42:01 PDT ---
Adding the dot is so trivial and takes no time at all. I do believe that this is indeed a bug anyway explanation of such:

This code will not compile:

class A
{
    void func();
    func getFunc()
    {
        return null;
    }
}
void main()
{
}


You cannot return a 'func' as it is not a type. 'func' is actually an instance of 'delegate' so it should have been declared as that.


class A
{
    void func();
    void getFunc()
    {
        new func();
    }
}
void main()
{
}

Here 'getFunc' is declared as void but it doesn't compile either because this time I am trying to new a 'func' which causes a compile error again because 'func' is not a type but an instance of delegate.

Whenever a peice of D code contains 2 identifiers next to each other like so:

AB XY

It can only mean either XY is an instance (whether that be value, ref, of function returning) and AB is a type. Likewise I can't 'new' everything either.

The bug is simply that dmdfe wasn't attempting to find a type or instance with the particular name but it was satisfied with the first symbol it found.

If this indeed hard to fixup now (and I would rather Walter focus on more
important issues) then adding a couple of dots is something I wouldn't mind to
do either (it would require a few bytes of code)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 09, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3231


Stewart Gordon <smjg@iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |spec




--- Comment #13 from Stewart Gordon <smjg@iname.com>  2009-08-09 09:38:26 PDT ---
I think comment 3 pretty much covers it, but is this stated in the spec?

FTR here are two closely related examples that fail:

----- overload_scope_1.d -----
void func(int i) {}

class C {
    static {
        void func() {}
        void func(string s) {}
        void test() {
            func();
            func(42); // line 9
            func("test");
        }
    }
}
----------
overload_scope_1.d(9): Error: function overload_scope_1.C.func () does not
match parameter types (int)
overload_scope_1.d(9): Error: cannot implicitly convert expression (42) of type
int to immutable(char)[]
overload_scope_1.d(9): Error: cannot cast int to immutable(char)[]

----- overload_scope_2.d -----
import overload_scope_2a;
import overload_scope_2b;

Qwert yuiop;
----- overload_scope_2a.d -----
alias string Qwert;
----- overload_scope_2b.d -----
void Qwert() {}
----------
overload_scope_2.d(4): Error: overload_scope_2a.Qwert at overload_scope_2a.d(1)
conflicts with overload_scope_2b.Qwert at overload_scope_2b.d(1)
----------

(DMD 2.031 Win; messages essentially the same in DMD 1.046.)

These cases show that it's down to two things:
- overload sets apply only between imported modules, not between scoping levels
- in any case, they apply only between function overloads, not between
arbitrarily mixed entity types

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 09, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3231





--- Comment #14 from BCS <shro8822@vandals.uidaho.edu>  2009-08-09 11:59:46 PDT ---
(In reply to comment #8)
> @BCS
> That case is indeed illegal, AND handled correctly by my fix.
> 

Given that you are willing to redefine the language I have to ask; What is correctly?

Assuming you are allowing it:

Even if you can make D handle the case, unless you can point at another .NET language (one that MS supports) that supports having both a function and a type with the same name in the same scope, I think it would be a bad idea to let D.NET do this.

What happens when you use such a type from c#? What does it give you when you use F12 on the reused name?

Adding this requires changing the specification of the D language and maybe even the whole .NET system. I would be uncomfortable with any change at all and would I wouldn't actively oppose a change that allows for both a member and a type in a class to have the same name.

Assuming you are disallowing it:

You are adding nothing to the language. Using fully qualified names (or .identifier) gets the same end effect.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 09, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3231





--- Comment #15 from BCS <shro8822@vandals.uidaho.edu>  2009-08-09 12:02:15 PDT ---
(In reply to comment #9)
> 
> Better beware of hijacking vulnerabilities.

class Foo {}

class Bar
{
    int Foo(){}

    // this would become a conflict with only an arbitrary resolution.
    alias Foo Baz;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
1 2
Next ›   Last »