Bug 8270 – Different error messages for missing const in var[] and var.opSlice()
Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2012-06-20T01:19:00Z
Last change time
2012-12-26T16:11:30Z
Keywords
diagnostic
Assigned to
nobody
Creator
xammy
Comments
Comment #0 by xammy — 2012-06-20T01:19:59Z
Consider the following code:
struct S
{
void opSlice() { }
}
void main()
{
const(S) s;
s[];
s.opSlice();
}
It results in two error messages from which the second is correct since it comlains about opSlice not being const but s being a const(S). The first one misses this information.
Error: function main.S.opSlice () is not callable using argument types ()
Error: function main.S.opSlice () is not callable using argument types () const
This bug does not seem to affect other operators like opIndex or opCall.
Comment #1 by andrej.mitrovich — 2012-12-26T16:11:04Z
Fixed in 2.061, both messages are like #2 now.
However it will also get better after pull 1407 is merged (http://d.puremagic.com/issues/show_bug.cgi?id=8270):
test.d(12): Error: mutable method test.S.opSlice is not callable using const object
test.d(13): Error: mutable method test.S.opSlice is not callable using const object
Comment #2 by andrej.mitrovich — 2012-12-26T16:11:30Z