[Issue 22818] New: typesafe variadic function parameter of type class should be scope

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 23 08:56:07 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=22818

          Issue ID: 22818
           Summary: typesafe variadic function parameter of type class
                    should be scope
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: bugzilla at digitalmars.com

https://dlang.org/spec/function.html#typesafe_variadic_functions

Class objects can be allocated on the stack, so a typesafe variadic class
parameter should automatically be scope.

  @safe:

  class C { int x; }

  ref int g(scope C c ...) {
    return c.x;
  }

correctly issues error: scope variable `c` may not be returned

but,

  ref int g(scope C c ...) {
    return c.x;
  }

erroneously compiles without error.

--


More information about the Digitalmars-d-bugs mailing list