D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7846 - Forward referenced storage class is not applied in certain cases
Summary: Forward referenced storage class is not applied in certain cases
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-06 02:26 UTC by timon.gehr
Modified: 2020-08-04 03:40 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description timon.gehr 2012-04-06 02:26:03 UTC
static assert(is(typeof(x)==const(int))); // pass
static assert(!is(typeof({x=2;}))); // pass
pragma(msg, typeof(x)); // "int"
pragma(msg, is(typeof({x=2;}))); // "true"
const int x;
pragma(msg, typeof(x)); // "const(int)"
pragma(msg, is(typeof({x=2;}))); // "false"
Comment 1 SomeDude 2012-04-21 11:03:06 UTC
I don't understand. I have to add const int x; at the beginning in order for this test to pass.
Then I get:
PS E:\DigitalMars\dmd2\samples> dmd -c bug.d
const(int)
false
bug.d(11): Error: declaration bug.main.x is already defined
const(int)
false
Comment 2 timon.gehr 2012-04-21 11:08:46 UTC
There is no 'main' in the test case in the bug report. The declarations reside at module scope.

To clarify: the issue is that the first two pragma(msg,...) print a wrong value.
Comment 3 Mathias LANG 2020-08-04 03:40:31 UTC
Fixed in v2.084:

```
2.063   to 2.083.1: Success with output:
-----
int
true
const(int)
false
-----

Since      2.084.1: Success with output:
-----
const(int)
false
const(int)
false
-----
```