digitalmars.D.bugs - [Issue 23948] New: __FILE__ and __MODULE__ cannot be implicitly
- d-bugmail puremagic.com (35/35) May 30 2023 https://issues.dlang.org/show_bug.cgi?id=23948
https://issues.dlang.org/show_bug.cgi?id=23948 Issue ID: 23948 Summary: __FILE__ and __MODULE__ cannot be implicitly converted to const(char)* as default paramenter Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: mail ernestocastellotti.it One expects this code to be valid: void foo(const(char)* mod = __MODULE__)() { } void main() { foo(); } However you get the error: onlineapp.d(9): Error: cannot implicitly convert expression `"onlineapp.d"` of type `string` to `const(char)*` onlineapp.d(9): Error: template instance `foo!((__error))` incompatible arguments for template instantiation onlineapp.d(9): Error: none of the overloads of template `onlineapp.foo` are callable using argument types `!()()` onlineapp.d(3): Candidate is: `foo(const(char)* mod = __FILE__) While if you do the same with __FUNCTION__ the code compiles: void foo(const(char)* fun = __FUNCTION__)() { } void main() { foo(); } --
May 30 2023