www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4283] New: static if with dangling else clause

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4283

           Summary: static if with dangling else clause
           Product: D
           Version: future
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2010-06-06 06:34:41 PDT ---
This D2 program compiles and runs with v2.046, but the syntax is wrong:


template Foo(bool b) {
    static if (b)
        enum bool Foo = 1;
    else
}
static assert(Foo!(true) == 1);
void main() {}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 06 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4283



--- Comment #1 from Ellery Newcomer <ellery-newcomer utulsa.edu> 2010-06-06
12:15:49 PDT ---
Created an attachment (id=658)
rearranged parseBlock a bit for better error messages

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 06 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4283



--- Comment #2 from Ellery Newcomer <ellery-newcomer utulsa.edu> 2012-08-12
23:51:08 PDT ---
The problem is if parseBlock encounters a rcurly, it consumes nothing.
Otherwise, it will consume

{ decldefs }
: decldefs
decldefs
;

As near as I can tell, consuming nothing serves no purpose in the parser, but
it does allow the following:

class C{
    public
}
struct S{
    static auto
}
interface F{
    extern(C)
}
union Z{
    extern private
}

class C2{
    align
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 12 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4283


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|patch                       |pull


--- Comment #3 from Kenji Hara <k.hara.pg gmail.com> 2012-10-27 07:34:11 PDT ---
https://github.com/D-Programming-Language/dmd/pull/1230

If DeclDefs is required just one declaration but there is no declaration,
parseDeclDefs should raise a syntax error.

I think my pull request is much simpler than the original patch.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 27 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4283



--- Comment #4 from github-bugzilla puremagic.com 2012-10-27 08:43:28 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/7f91fe6c8cd379f8f9d2ab92f3dad32791e35624
fix Issue 4283 - static if with dangling else clause

https://github.com/D-Programming-Language/dmd/commit/9d7f15ae8135db7e3461efd584d824063572c984
Merge pull request #1230 from 9rnsr/fix4283

Issue 4283 - static if with dangling else clause

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 27 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4283


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies gmail.com
           Platform|x86                         |All
            Version|D1 & D2                     |D1
            Summary|static if with dangling     |(D1 only) static if with
                   |else clause                 |dangling else clause
         OS/Version|Windows                     |All


--- Comment #5 from yebblies <yebblies gmail.com> 2012-10-28 02:47:21 EST ---
Fixed D2

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 27 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4283


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #6 from Kenji Hara <k.hara.pg gmail.com> 2012-11-08 09:29:15 PST ---
Fixed D1:
https://github.com/D-Programming-Language/dmd/commit/a3993d4d56b129bafa2466f7c99c9a8c4e4b65bc

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