Bug 18829 – pragma msg of int incoherent

Status
RESOLVED
Resolution
WORKSFORME
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-05-05T14:06:06Z
Last change time
2023-05-05T09:42:03Z
Assigned to
No Owner
Creator
Oliver Rümpelein

Comments

Comment #0 by oli_r — 2018-05-05T14:06:06Z
When working with pragma(msg,...) in relation to https://issues.dlang.org/show_bug.cgi?id=7947 I stumbled upon the following behaviour: pragma(msg, typeof(int.init)); // Works: int pragma(msg, int); // Fails: // Error: found `)` when expecting `.` following int // Error: found `;` when expecting identifier following `int`. // ... // but, obviously: static assert(is(typeof(int.init) == int)); This seems to be related to `int` being a keyword, as everything works when using an arbitrary struct.
Comment #1 by oli_r — 2018-05-11T07:41:43Z
Here is an example, with the problematic line 14 commented out: https://run.dlang.io/is/xzgt0E This fails with all primitive types. I would expect the last line to just print "int", or give a useful error message that primitive types can not be used there, but it looks more like a logical error in the parser.
Comment #2 by dkorpel — 2022-11-06T17:19:56Z
According to the grammar, a pragma takes an argument list, which is a list of expressions. D has no first class types; a plain `int` is not an expression. This is either an enhancement request to expand what pragma msg accepts, or to improve the error message when passing a basic type as an expression.
Comment #3 by razvan.nitu1305 — 2023-05-05T09:42:03Z
This has been fixed. The code in the original bug report now successfully compiles outputting int in both situations.