-
-
Notifications
You must be signed in to change notification settings - Fork 613
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix 18472: betterC cannot use format at compile time.
- Loading branch information
Etienne Cimon
committed
Dec 7, 2022
1 parent
0629537
commit fb14d42
Showing
8 changed files
with
57 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/*******************************************/ | ||
// https://issues.dlang.org/show_bug.cgi?id=18472 | ||
@nogc nothrow pure: | ||
immutable(Char)[] format(Char, Args...)(in Char[] fmt, Args args) | ||
{ | ||
if (__ctfe) { | ||
auto data2 = new char[5]; | ||
auto data = new Data2; | ||
data2 = cast(char[]) "test2"; | ||
return data2; | ||
} else { | ||
return "test"; | ||
} | ||
} | ||
|
||
extern(C) void main() | ||
{ | ||
static assert("%s %s".format("test", "test") == "test2", "Not working"); | ||
assert("%s %s".format("test", "test") == "test", "%s %s".format("test", "test")); | ||
assert(getData() == "test2", getData()); | ||
} | ||
|
||
string getData() { | ||
if (__ctfe) { | ||
auto data2 = new ubyte[5]; | ||
auto data = new Data2; | ||
return "test"; | ||
} else { | ||
return "test2"; | ||
} | ||
} | ||
|
||
private struct Data2 | ||
{ | ||
size_t capacity; | ||
} |