www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19210] New: Poor error message for `return` function


          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 puremagic.com
          Reporter: slavo5150 yahoo.com


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


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

Aug 31 2018