D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7979 - Alias this does not work with switch
Summary: Alias this does not work with switch
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: pull, rejects-valid
: 13820 (view as issue list)
Depends on:
Blocks:
 
Reported: 2012-04-24 09:54 UTC by Robert Clipsham
Modified: 2016-09-18 19:24 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 Robert Clipsham 2012-04-24 09:54:09 UTC
struct A {
    int a;
    alias a this;
}
void main() {
    A t;
    switch(t) {
        default:
    }
}

With dmd 2.059 this results in:
test.d(7): Error: 't' is not of integral type, it is a A

I believe the alias this should allow this to work.
Comment 1 Luís Marques 2015-09-30 02:39:41 UTC
I was bitten and surprised by this bug... Any plans to fix this?
Comment 3 github-bugzilla 2015-09-30 22:05:33 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/6b848c352f0865986fc6a0ed9e09effc4f014458
fix Issue 7979 - Alias this does not work with switch

https://github.com/D-Programming-Language/dmd/commit/ae47818a061e88325b629af185b06024424f70ce
Merge pull request #5146 from 9rnsr/fix7979

Issue 7979 - Alias this does not work with switch
Comment 4 Martin Krejcirik 2016-09-18 19:24:38 UTC
*** Issue 13820 has been marked as a duplicate of this issue. ***