Bug 19454 – Name collisions with unnamed function parameters
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-11-30T18:38:37Z
Last change time
2023-05-01T16:42:32Z
Keywords
bootcamp, patch, pull
Assigned to
No Owner
Creator
Neia Neutuladh
Comments
Comment #0 by dhasenan — 2018-11-30T18:38:37Z
Example:
---
void foo(int _param_1, int) {}
---
Result is a compile error:
Error: function `scratch.foo` parameter foo._param_1 is already defined
Double-underscore identifiers are reserved by the compiler, but other identifiers are not. The fix is to change _param_[index] to __param_[index], presumably. That won't change the name collision, but it will at least move it to "here be dragons" territory instead of "this looks like it should work".
Comment #1 by b2.temp — 2019-12-12T01:13:34Z
---
diff --git a/src/dmd/semantic3.d b/src/dmd/semantic3.d
index 7b08f3639..6e34ed7db 100644
--- a/src/dmd/semantic3.d
+++ b/src/dmd/semantic3.d
@@ -439,7 +439,7 @@ private extern(C++) final class Semantic3Visitor : Visitor
/* Generate identifier for un-named parameter,
* because we need it later on.
*/
- fparam.ident = id = Identifier.generateId("_param_", i);
+ fparam.ident = id = Identifier.generateId("__param_", i);
stc |= STC.temp;
}
Type vtype = fparam.type;
---
Comment #2 by razvan.nitu1305 — 2023-04-25T14:30:03Z
*** Issue 19578 has been marked as a duplicate of this issue. ***
Comment #3 by dlang-bot — 2023-05-01T14:04:09Z
@dkorpel created dlang/dmd pull request #15153 "Fix 19454 - Name collisions with unnamed function parameters" fixing this issue:
- Fix 19454 - Name collisions with unnamed function parameters
https://github.com/dlang/dmd/pull/15153
Comment #4 by dlang-bot — 2023-05-01T16:42:32Z
dlang/dmd pull request #15153 "Fix 19454 - Name collisions with unnamed function parameters" was merged into master:
- ba2f9222fd46cb450332dbad776b19767d3f2d42 by Dennis Korpel:
Fix 19454 - Name collisions with unnamed function parameters
https://github.com/dlang/dmd/pull/15153