Bug 13656 – clarify error message upon trying to declare a variable of type ref

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2014-10-25T16:15:01Z
Last change time
2023-01-05T08:34:12Z
Keywords
bootcamp, diagnostic, pull
Assigned to
No Owner
Creator
Shriramana Sharma

Comments

Comment #0 by samjnaa — 2014-10-25T16:15:01Z
Hello. The following code: void main () { int i ; ref ir = i ; } produces the following error message: "variable ref_type.main.ir only parameters or foreach declarations can be ref" The sentence is unclear "variable x only ... can be ref". What is meant is "Attempt to declare variable of type ref". Please clarify this. Also, please add ", return values" after "parameters" in the above error message since code like: ref int foo(ref int x) { return x ; } is permitted.
Comment #1 by samjnaa — 2015-10-17T14:09:13Z
*** Issue 15216 has been marked as a duplicate of this issue. ***
Comment #2 by samjnaa — 2015-10-17T14:11:06Z
Hmm... I seemed to have filed bug 13655 separately, but it's closely related to this one.
Comment #3 by dlang-bot — 2023-01-03T19:20:18Z
@ntrel created dlang/dmd pull request #14780 "Tweak punctuation for 3 error messages" fixing this issue: - Tweak punctuation for 3 error messages Fix Issue 13656 - clarify error when trying to declare a variable of type ref. Tweak 2 inout errors. https://github.com/dlang/dmd/pull/14780
Comment #4 by dlang-bot — 2023-01-05T08:34:12Z
dlang/dmd pull request #14780 "[dsymbolsem] Tweak punctuation for 3 error messages" was merged into master: - a5c0c346c21130a2630d7564358ea64eb1453533 by Nick Treleaven: Tweak punctuation for 3 error messages Fix Issue 13656 - clarify error when trying to declare a variable of type ref. Tweak 2 inout errors. https://github.com/dlang/dmd/pull/14780