Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions changelog.dd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ $(BUGSTITLE Language Changes,
)

$(LI $(RELATIVE_LINK2 align_by_ctfe, Align attribute can be used with CTFEable expression.))

$(LI $(RELATIVE_LINK2 deprecated_implicit_cat, Implicit string concatenation is deprecated.))
)

$(BUGSTITLE Compiler Changes,
Expand Down Expand Up @@ -202,6 +204,22 @@ $(BUGSTITLE Compiler Changes,
---
$(P The number after `spec:` is the nesting of the speculative compiles.)
)

$(LI $(LNAME2 deprecated_implicit_cat, Implicit string concatenation is deprecated.)

$(P Implicit concatenation of string literal is a very early feature that is now supplanted
by the concatenation operator ('~'), the later being more explicit.)

$(P It could result in hard to spot bug, where one missed a coma in an array expression:)

---
void foo ()
{
string[] arr = [ "Hello", "buggy" "World" ];
assert(arr.length = 3); // Fail, the length of the array is 2 and the content is [ "Hello", "buggyWorld" ]
}
---
)
)

Macros:
Expand Down
4 changes: 4 additions & 0 deletions src/parse.d
Original file line number Diff line number Diff line change
Expand Up @@ -7192,6 +7192,7 @@ final class Parser : Lexer
auto postfix = token.postfix;
while (1)
{
const prev = token;
nextToken();
if (token.value == TOKstring || token.value == TOKxstring)
{
Expand All @@ -7202,6 +7203,9 @@ final class Parser : Lexer
postfix = token.postfix;
}

deprecation("Implicit string concatenation is deprecated, use %s ~ %s instead",
prev.toChars(), token.toChars());

const len1 = len;
const len2 = token.len;
len = len1 + len2;
Expand Down
38 changes: 19 additions & 19 deletions test/d_do_test.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ import core.sys.posix.sys.wait;
void usage()
{
write("d_do_test <input_dir> <test_name> <test_extension>\n"
"\n"
" input_dir: one of: compilable, fail_compilation, runnable\n"
" test_name: basename of test case to run\n"
" test_extension: one of: d, html, or sh\n"
"\n"
" example: d_do_test runnable pi d\n"
"\n"
" relevant environment variables:\n"
" ARGS: set to execute all combinations of\n"
" REQUIRED_ARGS: arguments always passed to the compiler\n"
" DMD: compiler to use, ex: ../src/dmd\n"
" CC: C++ compiler to use, ex: dmc, g++\n"
" OS: win32, win64, linux, freebsd, osx\n"
" RESULTS_DIR: base directory for test results\n"
" windows vs non-windows portability env vars:\n"
" DSEP: \\\\ or /\n"
" SEP: \\ or /\n"
" OBJ: .obj or .o\n"
" EXE: .exe or <null>\n");
~ "\n"
~ " input_dir: one of: compilable, fail_compilation, runnable\n"
~ " test_name: basename of test case to run\n"
~ " test_extension: one of: d, html, or sh\n"
~ "\n"
~ " example: d_do_test runnable pi d\n"
~ "\n"
~ " relevant environment variables:\n"
~ " ARGS: set to execute all combinations of\n"
~ " REQUIRED_ARGS: arguments always passed to the compiler\n"
~ " DMD: compiler to use, ex: ../src/dmd\n"
~ " CC: C++ compiler to use, ex: dmc, g++\n"
~ " OS: win32, win64, linux, freebsd, osx\n"
~ " RESULTS_DIR: base directory for test results\n"
~ " windows vs non-windows portability env vars:\n"
~ " DSEP: \\\\ or /\n"
~ " SEP: \\ or /\n"
~ " OBJ: .obj or .o\n"
~ " EXE: .exe or <null>\n");
}

enum TestMode
Expand Down
7 changes: 4 additions & 3 deletions test/fail_compilation/diag10805.d
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/*
TEST_OUTPUT:
---
fail_compilation/diag10805.d(10): Error: delimited string must end in FOO"
fail_compilation/diag10805.d(12): Error: unterminated string constant starting at fail_compilation/diag10805.d(12)
fail_compilation/diag10805.d(13): Error: semicolon expected following auto declaration, not 'EOF'
fail_compilation/diag10805.d(11): Error: delimited string must end in FOO"
fail_compilation/diag10805.d(13): Error: unterminated string constant starting at fail_compilation/diag10805.d(13)
fail_compilation/diag10805.d(13): Deprecation: Implicit string concatenation is deprecated, use "" ~ "" instead
fail_compilation/diag10805.d(14): Error: semicolon expected following auto declaration, not 'EOF'
---
*/

Expand Down
14 changes: 14 additions & 0 deletions test/fail_compilation/issue3827.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// REQUIRED_ARGS: -de
/*
TEST_OUTPUT:
---
fail_compilation/issue3827.d(12): Deprecation: Implicit string concatenation is deprecated, use "Hello" ~ "World" instead
fail_compilation/issue3827.d(13): Deprecation: Implicit string concatenation is deprecated, use "A" ~ "B" instead
---
*/

void main ()
{
string[] arr = [ "Hello" "World" ];
auto foo = "A" "B";
}