D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6330 - Cannot disable assignment to a struct.
Summary: Cannot disable assignment to a struct.
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: accepts-invalid, patch
Depends on:
Blocks:
 
Reported: 2011-07-15 20:07 UTC by David Simcha
Modified: 2011-11-14 13:32 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description David Simcha 2011-07-15 20:07:41 UTC
struct S {
    void opAssign(S s) @disable {
        assert(0);  // This fails.
    }
}

void main() {
    S s;
    S s2;
    s2 = s;
}
Comment 1 Kenji Hara 2011-11-13 06:28:58 UTC
https://github.com/D-Programming-Language/dmd/pull/508

This is parser issue, that the postfix @disable attribute is ignored.

The workaround is moving @disable into head.

struct S {
    @disable void opAssign(S s){
        assert(0);  // This fails.
    }
}
void main() {
    S s;
    S s2;
    s2 = s;
    // Error: function test.S.opAssign is not callable because it is annotated with @disable
}