Bug 22818 – typesafe variadic function parameter of type class should be scope

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-02-23T08:56:07Z
Last change time
2022-02-24T10:11:21Z
Keywords
pull, safe
Assigned to
No Owner
Creator
Walter Bright

Comments

Comment #0 by bugzilla — 2022-02-23T08:56:07Z
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.
Comment #1 by bugzilla — 2022-02-24T02:45:40Z
Oops, the second example should be: > ref int g(C c ...) { > return c.x; > }
Comment #2 by dlang-bot — 2022-02-24T02:46:49Z
@WalterBright created dlang/dmd pull request #13714 "fix Issue 22818 - typesafe variadic function parameter of type class …" fixing this issue: - fix Issue 22818 - typesafe variadic function parameter of type class should be scope https://github.com/dlang/dmd/pull/13714
Comment #3 by dlang-bot — 2022-02-24T10:11:21Z
dlang/dmd pull request #13714 "fix Issue 22818 - typesafe variadic function parameter of type class …" was merged into master: - c6fba23e8ddeddb7ebe8f83fd410283f35e24ede by Walter Bright: fix Issue 22818 - typesafe variadic function parameter of type class should be scope https://github.com/dlang/dmd/pull/13714