Skip to content

Commit

Permalink
fix Bugzilla 23803 - compile-time error for concatenation in -betterC
Browse files Browse the repository at this point in the history
Signed-off-by: royalpinto007 <[email protected]>
  • Loading branch information
royalpinto007 committed Dec 7, 2024
1 parent a8e1ea6 commit 86d6b59
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dmd/e2ir.d
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Check warning on line 1745 in compiler/src/dmd/e2ir.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/e2ir.d#L1745

Added line #L1745 was not covered by tests
return el_long(TYint, 0);
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/test/fail_compilation/test18312.d
Original file line number Diff line number Diff line change
Expand Up @@ -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.
---
*/

Expand Down
2 changes: 1 addition & 1 deletion compiler/test/fail_compilation/test23710.d
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 20 additions & 0 deletions compiler/test/fail_compilation/test23803.d
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit 86d6b59

Please sign in to comment.