Jump to page: 1 2 3
Thread overview
March 11, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3934

           Summary: Some untidy attributes
           Product: D
           Version: 2.041
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid, rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2010-03-11 14:08:26 PST ---
This D2 program compiles and runs with no errors or warnings:


static foo1() {}
final foo2() {}
ref foo3() {}
enum void foo4() {}
nothrow foo5() {}
pure foo6() {}
static int x1 = 10;
static x2 = 10;
void main() {}


Notes:
- foo1, x1, x2: I don't know what a static global void function/variable is in
D2, so 'static' can be disallowed for global functions/variables.
- foo2, foo3, foo4: they look like bugs.
- Are most of those attributes supposed to not need the "void"? I think
requiring for example "pure void" is a little better than allowing just "pure".


The following lines don't compile, is this correct?

int static x3 = 10;
int enum x4 = 1;
int const x5 = 2;


I like the strictness of the Java compiler, it makes sure your attributes are all correct and meaningful, this helps avoid possible bugs. And I'm sure it helps newbies learn the language in less time too (because when you don't know the rules yet, it's very useful if they don't change).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 14, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3934



--- Comment #1 from bearophile_hugs@eml.cc 2010-04-14 07:35:46 PDT ---
A person in the IRC channel suggests that this too can be bad (this program compiles and runs with dmd 2.043):

extern struct foo;
void main() {}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 30, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3934


Stewart Gordon <smjg@iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg@iname.com


--- Comment #2 from Stewart Gordon <smjg@iname.com> 2010-05-30 14:21:25 PDT ---
This seems to be partly a duplicate of issue 3118.

Without a clear spec on the matter, it's hard to decide which of these it's a bug that the compiler accepts, but certainly foo3 and foo4 AISI.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 16, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3934



--- Comment #3 from bearophile_hugs@eml.cc 2010-06-15 17:10:04 PDT ---
This too is wrong (this compiles with dmd v2.047):


struct Foo {
    static invariant() {}
}
void main() {}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 30, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3934



--- Comment #4 from bearophile_hugs@eml.cc 2010-06-30 13:14:48 PDT ---
One from Leopold Walkling, this compiles:

auto void main() {}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 30, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3934



--- Comment #5 from Stewart Gordon <smjg@iname.com> 2010-06-30 16:33:29 PDT ---
I certainly call that a bug.

Partly a consequence of auto being an attribute rather than a placeholder for a type, though this seems to be partly for backward compatibility with the old meaning of auto.  Either way, it's an inapplicable attribute and one that ought not to be accepted.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 25, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3934



--- Comment #6 from bearophile_hugs@eml.cc 2010-07-25 07:01:22 PDT ---
Two more related cases:

This looks correct:

auto main() {
    return 0;
}

But dmd 2.047 prints:
test.d(1): Error: function D main must return int or void

----------------

The error message shows that foo() is not pure:
test.d(5): Error: pure function 'bar' cannot call impure function 'foo'


auto pure foo() {
    return 1;
}
pure void bar() {
    foo();
}
void main() {}


So it seems 'pure' is ignored if 'auto' is present.

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



--- Comment #7 from bearophile_hugs@eml.cc 2010-08-17 06:07:58 PDT ---
From Simen kjaeraas:

__gshared struct foo {
    int n;
}

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



--- Comment #8 from bearophile_hugs@eml.cc 2010-08-19 06:14:56 PDT ---
From bernardh on IRC, this program compiles:

auto scope shared import std.stdio;
void main() {}

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



--- Comment #9 from bearophile_hugs@eml.cc 2010-08-19 09:11:44 PDT ---
This D2 program compiles and runs with DMD 2.048 with no errors, but I think the compiler has to flag this usage of the 'private final' attributes as incorrect:


import std.c.stdio: puts;
class Base {
     private final ~this() { puts("Base.~this"); }
}
class Derived : Base {
    private final ~this() { puts("Derived.~this"); }
}
void main() {
    new Derived();
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2 3