Bug 16640 – void fun(string file=__FILE_FULL_PATH__) returns relative path

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2016-10-26T21:35:47Z
Last change time
2017-08-16T13:22:47Z
Assigned to
No Owner
Creator
Timothee Cour

Comments

Comment #0 by timothee.cour2 — 2016-10-26T21:35:47Z
DMD64 D Compiler v2.073.0-devel-aea0dec dmd -run main.d ``` import std.stdio; void main(){ fun(); } void fun(string file=__FILE_FULL_PATH__){ string file2=__FILE_FULL_PATH__; assert(file==file2, file~" "~file2);// fails } ```
Comment #1 by timothee.cour2 — 2017-01-06T21:16:24Z
ping
Comment #2 by timothee.cour2 — 2017-01-09T08:48:39Z
introduced here: 67d08406f7451954cd8caf5faea6a2a87244f8e7 by: Author: Jonathan Marler <[email protected]>
Comment #3 by johnnymarler — 2017-01-09T16:52:57Z
The __FILE_FULL_PATH__ macro is a feature that I added to the DMD compiler in the commit you referenced (67d08406f7451954cd8caf5faea6a2a87244f8e7). I never tested using it as a default argument to a function parameter so it looks like you've found a bug. You are welcome to fix this. If you decide to fix it, I would also add a unit test. The original unit test I added for this feature is in <dmd>/test/compilable/line.d, it may or may not be the correct place for the new unit test, but it should definitely be added somewhere. Maybe a test like this: void testFileFullPathAsDefaultArgument(string preBakedFileFullPath, string fileFullPath = __FILE_FULL_PATH__) { assert(preBakedFileFullPath == fileFullPath); } testFileFullPathAsDefaultArgument(__FILE_FULL_PATH__); Let me know if you have any questions. P.S. Just out of curiosity, what were you using this macro for? I spent alot of time convincing the D maintainers that it was a useful feature so I'm curious what uses people have found for it.
Comment #4 by timothee.cour2 — 2017-01-09T17:50:29Z
Just thought about introducing __DIR__ instead, see my post: http://forum.dlang.org/post/[email protected] __DIR__ trait (return getcwd at compile time), replacing __FILE_FULL_PATH__ [maybe reply in that post if you have some opinion on __DIR__ proposal] Thanks!
Comment #5 by razvan.nitu1305 — 2017-06-23T13:13:08Z
Comment #6 by github-bugzilla — 2017-07-02T03:29:12Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/a9f5d61756ed83fb37eb88601dd9065db16c33bd Fix Issue 16640 - void fun(string file=__FILE_FULL_PATH__) returns relative path https://github.com/dlang/dmd/commit/d7887fb8acc17f1d19fb0c23b4e7e4af371a6ee1 Merge pull request #6928 from RazvanN7/Issue_16640 Fix Issue 16640 - __FILE_FULL_PATH__ doesn't return relative path when used as default parameter merged-on-behalf-of: Andrei Alexandrescu <[email protected]>
Comment #7 by github-bugzilla — 2017-08-07T13:16:57Z
Commits pushed to newCTFE at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/a9f5d61756ed83fb37eb88601dd9065db16c33bd Fix Issue 16640 - void fun(string file=__FILE_FULL_PATH__) returns relative path https://github.com/dlang/dmd/commit/d7887fb8acc17f1d19fb0c23b4e7e4af371a6ee1 Merge pull request #6928 from RazvanN7/Issue_16640
Comment #8 by github-bugzilla — 2017-08-16T13:22:47Z
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/a9f5d61756ed83fb37eb88601dd9065db16c33bd Fix Issue 16640 - void fun(string file=__FILE_FULL_PATH__) returns relative path https://github.com/dlang/dmd/commit/d7887fb8acc17f1d19fb0c23b4e7e4af371a6ee1 Merge pull request #6928 from RazvanN7/Issue_16640