-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96a2729
commit a50339d
Showing
5 changed files
with
49 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Import expressions are now treated as hex strings | ||
|
||
While [Import expressions](https://dlang.org/spec/expression.html#import_expressions) are typed as `string`, they are also used to embed binary files. | ||
By treating them the same as hex strings, they will implicitly convert to arrays of integral types other than `char`. | ||
|
||
--- | ||
// Formerly, a cast was required: | ||
immutable ubyte[] iconImg = cast(immutable ubyte[]) import("icon.png"); | ||
|
||
// Now, it implicitly converts to integral arrays: | ||
immutable ubyte[] iconImg = import("icon.png"); | ||
--- |
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 @@ | ||
// REQUIRED_ARGS: -Jcompilable/imports/ | ||
// EXTRA_FILES: imports/imp16088.d imports/test21227/a..b.txt imports/test21227/a.txt imports/test21227/..foo/a.txt | ||
|
||
// https://issues.dlang.org/show_bug.cgi?id=16088 | ||
|
||
void bar(string x) {} | ||
auto foo() | ||
{ | ||
import("imp16088.d").bar; | ||
} | ||
|
||
|
||
// https://issues.dlang.org/show_bug.cgi?id=21227 | ||
|
||
void test21227() | ||
{ | ||
import("./test21227/a.txt").bar; | ||
import("test21227//a..b.txt").bar; | ||
import("test21227/..foo/a.txt").bar; | ||
|
||
version(Windows) | ||
{ | ||
import(r".\test21227\a.txt").bar; | ||
import(r"test21227\\a..b.txt").bar; | ||
import(r"test21227\..foo\a.txt").bar; | ||
} | ||
} | ||
|
||
// Test that it's treated like a hex string, allowing implicit conversion to byte array | ||
|
||
// Can't test whole contents because line endings may vary | ||
enum expectedStart = "module imports.imp16088;"; | ||
|
||
immutable ubyte[] s0 = import("imp16088.d"); | ||
|
||
static assert(s0[0 .. expectedStart.length] == "module imports.imp16088;"); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.