www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2652] New: DeclDef grammar is wrong

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

           Summary: DeclDef grammar is wrong
           Product: D
           Version: 2.023
          Platform: PC
               URL: http://www.digitalmars.com/d/2.0/module.html
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: www.digitalmars.com
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: jlquinn optonline.net
 BugsThisDependsOn: 2651


As described, the DeclDef grammar allows Invariant and UnitTest at module
scope.  The compiler only permits them within classes, structs, and unions,
which seems more correct to me.  Given that and bug 2651, I think the grammar
should be modified as:

Module:
        DeclDefs

DeclDefs:
        DeclDef
        DeclDef DeclDefs

DeclDef:
        AttributeSpecifier
        ImportDeclaration
        EnumDeclaration
        ClassDeclaration
        InterfaceDeclaration
        AggregateDeclaration
        Declaration
        UnitTest
        StaticConstructor
        StaticDestructor
        DebugSpecification
        VersionSpecification
        MixinDeclaration
        ;

ClassBodyDeclaration:
        AggregateDeclDef
        Constructor
        Destructor
        ClassAllocator
        ClassDeallocator

StructBodyDeclaration:
        AggregateDeclDef
        StructAllocator
        StructDeallocator
        StructConstructor
        StructPostblit
        StructDestructor

AggregateDeclDef:
        DeclDef
        Invariant
        UnitTest


-- 
Feb 08 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2652





------- Comment #1 from ddparnell bigpond.com  2009-02-08 23:51 -------
Unit tests are correctly permitted at the module level. A unit test can be used
to test free functions as well as class/struct methods.


-- 
Feb 08 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2652





------- Comment #2 from jlquinn optonline.net  2009-02-09 07:46 -------
(In reply to comment #1)
 Unit tests are correctly permitted at the module level. A unit test can be used
 to test free functions as well as class/struct methods.

Yes, I see that now. I'm now thinking that to make the distinction in the grammar you need two different versions of AttributeSpecifier - one for module scope that references DeclDef and another for class/struct scope where invariant is allowed. ClassBodyDeclaration and StructBodyDeclaration still need to reference some kind of DeclDef, though. --
Feb 09 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2652


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


--- Comment #3 from Walter Bright <bugzilla digitalmars.com> 2010-11-08
11:01:12 PST ---
http://www.dsource.org/projects/phobos/changeset/2136

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