[Issue 17638] New: A pragma inside a function body is seen as a statement

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Jul 11 22:04:01 PDT 2017


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 at puremagic.com
          Reporter: b2.temp at 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.

--


More information about the Digitalmars-d-bugs mailing list