www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17638] New: A pragma inside a function body is seen as a

https://issues.dlang.org/show_bug.cgi?id=17638

          Issue ID: 17638
           Summary: A pragma inside a function body is seen as a statement
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: b2.temp gmx.com

The pragma in this code:

    void foo(){pragma(bar);}

Is seen by the front-end as a statement (verified by putting some printf...).
According to the specifications:

- we're in a block so we have either DeclarationOrStatement s inside.
- "pragma(bar);" matches to the attribute declaration rule.
- "pragma(bar);" matches to the PragmaStatement rule too.

in http://dlang.org/spec/statement.html, just after the grammar table we can
read:

"Any ambiguities in the grammar between Statements and Declarations are
resolved by the declarations taking precedence".

By applying this rule of thumb, the front-end should rather see "pragma(bar);"
as a declaration.

--
Jul 11