Bug 17546 – Cannot call .stringof on a function symbol if it does not have a no-args overload

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-06-24T17:38:08Z
Last change time
2024-12-13T18:52:45Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
Meta
See also
https://issues.dlang.org/show_bug.cgi?id=1142
Moved to GitHub: dmd#19266 →

Comments

Comment #0 by monkeyworks12 — 2017-06-24T17:38:08Z
int test() { return 0; } void main() { pragma(msg, test.stringof); } It seems that the only way to make this work is add a no-args overload of `test`. It still seems that something weird is going on if I do that, however: int test() { return 0; } void main() { //Prints "test()" pragma(msg, test.stringof); } Currently I am resorting to a hacky workaround by doing `(&test).stringof[2..$]`.
Comment #1 by schveiguy — 2017-06-26T15:51:09Z
Correction, test has to take a parameter: int test(int) { return 0; } Error message: teststringof.d(8): Error: function teststringof.test (int _param_0) is not callable using argument types () teststringof.d(8): while evaluating pragma(msg, (__error).stringof)
Comment #2 by schveiguy — 2017-06-26T15:55:03Z
(In reply to monkeyworks12 from comment #0) > Currently I am resorting to a hacky workaround by doing > `(&test).stringof[2..$]`. I've found another possible workaround: __traits(identifier, test); // compile time literal of "test"
Comment #3 by monkeyworks12 — 2017-06-26T16:46:39Z
Ah, I forgot all about __traits(identifier). I wonder what the difference is between this and .stringof... Anyway, this should be a good enough workaround for the time being.
Comment #4 by b2.temp — 2018-05-04T23:12:10Z
Comment #5 by b2.temp — 2019-06-22T14:09:14Z
That's not a reg finally. UDA on params were added in 2.082, explaining why it was rejected in the past.
Comment #6 by robert.schadek — 2024-12-13T18:52:45Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19266 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB