Skip to content

Commit

Permalink
Merge pull request #6928 from RazvanN7/Issue_16640
Browse files Browse the repository at this point in the history
Fix Issue 16640 - __FILE_FULL_PATH__ doesn't return relative path when used as default parameter
merged-on-behalf-of: Andrei Alexandrescu <andralex@users.noreply.github.com>
  • Loading branch information
dlang-bot committed Jul 2, 2017
2 parents 2c02eb4 + a9f5d61 commit d7887fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ddmd/expression.d
Expand Up @@ -16032,6 +16032,8 @@ extern (C++) final class FileInitExp : DefaultInitExp
{
//printf("FileInitExp::resolve() %s\n", toChars());
const(char)* s = loc.filename ? loc.filename : sc._module.ident.toChars();
if (subop == TOKfilefullpath)
s = FileName.combine(sc._module.srcfilePath, s);
Expression e = new StringExp(loc, cast(char*)s);
e = e.semantic(sc);
e = e.castTo(sc, type);
Expand Down
11 changes: 11 additions & 0 deletions test/runnable/test16640.d
@@ -0,0 +1,11 @@
// PERMUTE_ARGS:

void testFileFullPathAsDefaultArgument(string preBakedFileFullPath, string fileFullPath = __FILE_FULL_PATH__)
{
assert(preBakedFileFullPath == fileFullPath);
}

void main()
{
testFileFullPathAsDefaultArgument(__FILE_FULL_PATH__);
}

0 comments on commit d7887fb

Please sign in to comment.