Bug 12967 – Prefix method 'this' qualifiers should be disallowed in DeclDefs scope
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-06-23T06:21:00Z
Last change time
2014-10-04T05:31:01Z
Keywords
pull
Assigned to
nobody
Creator
k.hara.pg
Comments
Comment #0 by k.hara.pg — 2014-06-23T06:21:35Z
Currently following three function declarations are compiled successfully.
const void prefix_f() {}
const { void block_f() {} }
const: void label_f() {}
But postfix stype method qualifier is disallowed.
void postfix_f() const {}
// Error: function test.postfix_f without 'this' cannot be const
This is introduced by fixing issue 10150.
There's pragmatic reason to accept block and label style.
const { // or label style
int var = 123; // qualified with const
... many variable declarations -> qualified with const
void foo() {} // just ignoring 'const' is useful than making error
... more variable declarations -> qualified with const
}
So I think that above behavior should be kept as-is.
But prefix style attributes always modify only one declaration.
So it would be more consistent behavior that raising same error in both prefix and postfix cases.
const void prefix_f() {}
void postfix_f() const {}
// Error: function test.prefix_f without 'this' cannot be const
// Error: function test.postfix_f without 'this' cannot be const