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
8 changes: 5 additions & 3 deletions compiler/src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -11013,7 +11013,9 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
(exp.e2.isStringExp() && (exp.e1.isIntegerExp() || exp.e1.isStringExp())))
return exp;

Identifier hook = global.params.tracegc ? Id._d_arraycatnTXTrace : Id._d_arraycatnTX;
bool useTraceGCHook = global.params.tracegc && sc.needsCodegen();

Identifier hook = useTraceGCHook ? Id._d_arraycatnTXTrace : Id._d_arraycatnTX;
if (!verifyHookExist(exp.loc, *sc, hook, "concatenating arrays"))
{
setError();
Expand Down Expand Up @@ -11042,7 +11044,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
}

auto arguments = new Expressions();
if (global.params.tracegc)
if (useTraceGCHook)
{
auto funcname = (sc.callsc && sc.callsc.func) ?
sc.callsc.func.toPrettyChars() : sc.func.toPrettyChars();
Expand All @@ -11069,7 +11071,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
/* `_d_arraycatnTX` canot be used with `-betterC`, but `CatExp`s may be
* used with `-betterC`, but only during CTFE.
*/
if (global.params.betterC || !sc.needsCodegen())
if (global.params.betterC)
return;

if (auto ce = exp.isCatExp())
Expand Down
15 changes: 15 additions & 0 deletions compiler/test/compilable/test24118.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// https://issues.dlang.org/show_bug.cgi?id=24118

void map(alias fun, T)(T[] arr)
{
fun(arr);
}


void foo()
{
if( __ctfe )
{
["a", "b", "c"].map!( a => " " ~ a[0] );
}
}