digitalmars.D.bugs - [Issue 20314] New: passing const variables to `only` forces const
- d-bugmail puremagic.com (28/28) Oct 24 2019 https://issues.dlang.org/show_bug.cgi?id=20314
https://issues.dlang.org/show_bug.cgi?id=20314 Issue ID: 20314 Summary: passing const variables to `only` forces const range element type Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: minor Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: default_357-line yahoo.de Consider this code: import std; void main() { const string s = "foo", t = "bar"; auto range = only(s, t); [range].joiner(only(", ")).join.writeln; } Since `only` takes its parameters by `auto ref`, the fact that s and t are `const string` forces `only` to have an `ElementType` of `const(string)`, which then breaks `joiner`. There's no reason for `only` to be `auto ref`, since it copies its parameters anyways. --
Oct 24 2019