mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
Add hint when declaring function with TypeCtor
This commit is contained in:
parent
76361f4c2b
commit
bc214e44d5
2 changed files with 12 additions and 4 deletions
|
@ -3385,9 +3385,13 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
|
||||||
|
|
||||||
if (!tf.isNaked() && !(funcdecl.isThis() || funcdecl.isNested()))
|
if (!tf.isNaked() && !(funcdecl.isThis() || funcdecl.isNested()))
|
||||||
{
|
{
|
||||||
OutBuffer buf;
|
import core.bitop;
|
||||||
MODtoBuffer(buf, tf.mod);
|
auto mods = MODtoChars(tf.mod);
|
||||||
.error(funcdecl.loc, "%s `%s` without `this` cannot be `%s`", funcdecl.kind, funcdecl.toPrettyChars, buf.peekChars());
|
.error(funcdecl.loc, "%s `%s` without `this` cannot be `%s`", funcdecl.kind, funcdecl.toPrettyChars, mods);
|
||||||
|
if (tf.next && tf.next.ty != Tvoid && popcnt(tf.mod) == 1)
|
||||||
|
.errorSupplemental(funcdecl.loc,
|
||||||
|
"did you mean to use `%s(%s)` as the return type?", mods, tf.next.toChars());
|
||||||
|
|
||||||
tf.mod = 0; // remove qualifiers
|
tf.mod = 0; // remove qualifiers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
/*
|
/*
|
||||||
TEST_OUTPUT:
|
TEST_OUTPUT:
|
||||||
---
|
---
|
||||||
fail_compilation/fail212.d(14): Error: function `fail212.S.bar` without `this` cannot be `const`
|
fail_compilation/fail212.d(10): Error: function `fail212.baz` without `this` cannot be `const`
|
||||||
|
fail_compilation/fail212.d(10): did you mean to use `const(int)` as the return type?
|
||||||
|
fail_compilation/fail212.d(18): Error: function `fail212.S.bar` without `this` cannot be `const`
|
||||||
---
|
---
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const int baz();
|
||||||
|
|
||||||
struct S
|
struct S
|
||||||
{
|
{
|
||||||
void foo() const
|
void foo() const
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue