Bug 24385 – Slicing a static array binds as non-ref when using auto ref

Status
NEW
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-02-10T16:49:35Z
Last change time
2024-12-13T19:33:14Z
Keywords
wrong-code
Assigned to
No Owner
Creator
Steven Schveighoffer
Moved to GitHub: dmd#20399 →

Comments

Comment #0 by schveiguy — 2024-02-10T16:49:35Z
```d import std.stdio; void foo(ref int[2] val) { writeln("foo ref"); } void foo(int[2] val) { writeln("foo non-ref"); } void bar()(auto ref int[2] val) { static if(__traits(isRef, val)) writeln("bar ref"); else writeln("bar non-ref"); } void main() { int[4] x; int[2] y; foo(y); // foo ref bar(y); // bar ref foo(x[0 .. 2]); // foo ref bar(x[0 .. 2]); // bar non-ref } ``` They should all be ref for consistency.
Comment #1 by robert.schadek — 2024-12-13T19:33:14Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20399 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB