Bug 19109 – [SPEC] handling of unknown pragmas inconsistent with spec
Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-07-22T17:10:07Z
Last change time
2023-12-31T22:35:09Z
Assigned to
Iain Buclaw
Creator
Iain Buclaw
Comments
Comment #0 by ibuclaw — 2018-07-22T17:10:07Z
According to https://dlang.org/spec/pragma.html
```
Pragmas can appear as either declarations, Pragma DeclarationBlock, or as statements, PragmaStatement.
---
1. pragma(ident);
2. pragma(ident) declaration_or_statement;
3. pragma(ident):
declaration;
declaration;
4. pragma(ident)
{
declaration_or_statement;
declaration_or_statement;
}
---
```
And yet item [2] doesn't seem to be the case, e.g:
```
pragma(msg, "test") // Error: missing a terminating ';'
void testA() { }
pragma(mangle, "test") // But this is OK
void testB() { }
pragma(custom_pragma) // Error: missing a terminating ';'
void testC() { }
```
The third example above is of main concern regarding the discrepancy. In the first example, an error would be expected as that particular pragma is only allowed as a statement by definition.