Bug 18633 – Specify clearly if `typectors ref` is the same as `typector auto ref `
Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P1
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-03-19T21:46:42Z
Last change time
2022-02-07T19:33:40Z
Assigned to
No Owner
Creator
Basile-z
Comments
Comment #0 by b2.temp — 2018-03-19T21:46:42Z
the compiler accepts
`auto ref inout(ElementType!Range) choice(Range, RandomGen = Random)(inout ref Range range, ref RandomGen urng){...}`
While a more correct form is
`auto ref inout(ElementType!Range) choice(Range, RandomGen = Random)(inout auto ref Range range, ref RandomGen urng){...}`
The specs don't say why and when `auto` can be omitted, they could be more accurate.
Problem encountered here: https://github.com/dlang/phobos/pull/6302#discussion_r175561789
Comment #1 by issues.dlang — 2018-03-19T22:11:32Z
Given that auto ref is supposed to be distinct from auto, I would expect it to be a compiler bug if ref with anything other than auto were treated the same as auto ref.
auto by itself is supposed to be a placeholder to indicate that a variable is being declared, and is unnecessary when another attribute or identifier clearly indicates that a variable is being declared, and that has nothing to with auto ref. But I have no idea how clear the spec is on that.