Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project.addTestRunnerConfiguration(): Don't accidentally modify base config's buildSettings #2300

Merged
merged 2 commits into from
Jul 13, 2022

Conversation

kinke
Copy link
Contributor

@kinke kinke commented Jul 13, 2022

This most likely doesn't affect dub itself, as it only works with a single configuration at a time. The problem has surfaced with reggae though (which can use multiple dub configurations at a time) - the mainSourceFile was removed from the base application config too.

…config's buildSettings

This most likely doesn't affect dub itself, as it only works with
a single configuration at a time. The problem has surfaced with reggae
though (which can use multiple dub configurations at a time) - the
`mainSourceFile` was removed from the base `application` config too.
@kinke kinke requested review from WebFreak001 and Geod24 July 13, 2022 15:47
@kinke
Copy link
Contributor Author

kinke commented Jul 13, 2022

[BuildSettings would have a .dup() method. Apparently very similar BuildSettings**Template** doesn't.]

@Geod24
Copy link
Member

Geod24 commented Jul 13, 2022

Maybe we could use

private T clone(T)(ref const(T) val)
{
import std.traits : isSomeString, isDynamicArray, isAssociativeArray, isBasicType, ValueType;
static if (is(T == immutable)) return val;
else static if (isBasicType!T) return val;
else static if (isDynamicArray!T) {
alias V = typeof(T.init[0]);
static if (is(V == immutable)) return val;
else {
T ret = new V[val.length];
foreach (i, ref f; val)
ret[i] = clone!V(f);
return ret;
}
} else static if (isAssociativeArray!T) {
alias V = ValueType!T;
T ret;
foreach (k, ref f; val)
ret[k] = clone!V(f);
return ret;
} else static if (is(T == struct)) {
T ret;
foreach (i, M; typeof(T.tupleof))
ret.tupleof[i] = clone!M(val.tupleof[i]);
return ret;
} else static assert(false, "Unsupported type: "~T.stringof);
}
?

@kinke
Copy link
Contributor Author

kinke commented Jul 13, 2022

Thx for the suggestion, much better now and still seems to work fine for reggae.

@Geod24 Geod24 merged commit 96d125b into dlang:master Jul 13, 2022
@kinke kinke deleted the dup_tcinfo branch July 13, 2022 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants