[Issue 19210] New: Poor error message for `return` function parameter that is not `ref`
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Aug 31 07:51:30 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=19210
Issue ID: 19210
Summary: Poor error message for `return` function parameter
that is not `ref`
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: slavo5150 at yahoo.com
@safe:
ref int identity(return ref int x)
{
return x;
}
ref int fun(return int x)
{
return identity(x); //Error: returning identity(x) escapes a reference to
parameter x, perhaps annotate with return
}
void main()
{
int i;
int j = fun(i);
}
$ dmd -dip25 main.d
https://run.dlang.io/is/lvvRUR
The problem is that `x`, in function `fun` is already annotated with `return`,
so the error message doesn't make sense. I believe there should be an error
message emitted disallowing `return` on parameters that are not `ref` or `out`,
but I'm not sure
--
More information about the Digitalmars-d-bugs
mailing list