[Issue 12967] New: Prefix method 'this' qualifiers should be disallowed in DeclDefs scope
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Jun 22 23:21:35 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12967
Issue ID: 12967
Summary: Prefix method 'this' qualifiers should be disallowed
in DeclDefs scope
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: k.hara.pg at gmail.com
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
--
More information about the Digitalmars-d-bugs
mailing list