diff --git a/compiler/src/dmd/e2ir.d b/compiler/src/dmd/e2ir.d index 1d1efd1f966..a266820d5c1 100644 --- a/compiler/src/dmd/e2ir.d +++ b/compiler/src/dmd/e2ir.d @@ -1742,7 +1742,7 @@ elem* toElem(Expression e, ref IRState irs) */ if (!irs.params.useGC) { - irs.eSink.error(ce.loc, "array concatenation of expression `%s` requires the GC which is not available with -betterC", ce.toChars()); + irs.eSink.error(ce.loc, "`%s` is not allowed in -betterC mode because it requires the garbage collector.", ce.toChars()); return el_long(TYint, 0); } diff --git a/compiler/test/fail_compilation/test18312.d b/compiler/test/fail_compilation/test18312.d index e354a11eae8..289ab33bba3 100644 --- a/compiler/test/fail_compilation/test18312.d +++ b/compiler/test/fail_compilation/test18312.d @@ -2,7 +2,7 @@ REQUIRED_ARGS: -betterC TEST_OUTPUT: --- -fail_compilation/test18312.d(14): Error: array concatenation of expression `"[" ~ s ~ "]"` requires the GC which is not available with -betterC +fail_compilation/test18312.d(14): Error: `"[" ~ s ~ "]"` is not allowed in -betterC mode because it requires the garbage collector. --- */ diff --git a/compiler/test/fail_compilation/test23710.d b/compiler/test/fail_compilation/test23710.d index e834b78f7d5..d1dd12f387a 100644 --- a/compiler/test/fail_compilation/test23710.d +++ b/compiler/test/fail_compilation/test23710.d @@ -1,7 +1,7 @@ /* REQUIRED_ARGS: -betterC TEST_OUTPUT: --- -fail_compilation/test23710.d(111): Error: array concatenation of expression `foo ~ [1, 2, 3]` requires the GC which is not available with -betterC +fail_compilation/test23710.d(111): Error: `foo ~ [1, 2, 3]` is not allowed in -betterC mode because it requires the garbage collector. --- */ // https://issues.dlang.org/show_bug.cgi?id=23710 diff --git a/compiler/test/fail_compilation/test23803.d b/compiler/test/fail_compilation/test23803.d new file mode 100644 index 00000000000..8f27b2de406 --- /dev/null +++ b/compiler/test/fail_compilation/test23803.d @@ -0,0 +1,20 @@ +// https://issues.dlang.org/show_bug.cgi?id=23803 + +/* +REQUIRED_ARGS: -betterC +TEST_OUTPUT: +--- +fail_compilation/test23803.d(14): Error: `a ~ b` is not allowed in -betterC mode because it requires the garbage collector. +--- +*/ + +string foo() +{ + string a, b; + return a ~ b; +} + +extern(C) void main() +{ + foo(); +}