Bug 23948 – __FILE__ and __MODULE__ cannot be implicitly converted to const(char)* as default paramenter

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2023-05-30T23:06:41Z
Last change time
2023-05-31T10:37:21Z
Keywords
pull
Assigned to
No Owner
Creator
mail

Comments

Comment #0 by mail — 2023-05-30T23:06:41Z
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(); }
Comment #1 by mail — 2023-05-30T23:07:10Z
I'm doing a PR to fix it
Comment #2 by dlang-bot — 2023-05-30T23:12:52Z
@ErnyTech created dlang/dmd pull request #15283 "Fix issue 23948 - __FILE__ and __MODULE__ cannot be implicitly converted to const(char)* as default paramenter" fixing this issue: - Fix issue 23948 - __FILE__ and __MODULE__ cannot be implicitly converted to const(char)* as default paramenter https://github.com/dlang/dmd/pull/15283
Comment #3 by dlang-bot — 2023-05-31T10:37:21Z
dlang/dmd pull request #15283 "Fix issue 23948 - __FILE__ and __MODULE__ cannot be implicitly converted to const(char)* as default paramenter" was merged into master: - 415d6bdb5388cfb92039a292ad2080a67ee57e5d by Ernesto Castellotti: Fix issue 23948 - __FILE__ and __MODULE__ cannot be implicitly converted to const(char)* as default paramenter https://github.com/dlang/dmd/pull/15283