From baf6ede6de920f17df6c48aa5eac32b6ea30ca10 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Wed, 14 Jul 2021 20:50:27 +0000 Subject: [PATCH] Fix Issue 22125 - std.process.Config was changed to a struct but miss operator overloads --- std/process.d | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/std/process.d b/std/process.d index 0eeb7095c..7ac26aff2 100644 --- a/std/process.d +++ b/std/process.d @@ -2131,9 +2131,20 @@ struct Config enum Config inheritFDs = Config(Flags.inheritFDs); /// ditto enum Config detached = Config(Flags.detached); /// ditto enum Config stderrPassThrough = Config(Flags.stderrPassThrough); /// ditto - Config opBinary(string op : "|")(Config other) + Config opUnary(string op)() + if (is(typeof(mixin(op ~ q{flags})))) { - return Config(flags | other.flags); + return Config(mixin(op ~ q{flags})); + } /// ditto + Config opBinary(string op)(Config other) + if (is(typeof(mixin(q{flags} ~ op ~ q{other.flags})))) + { + return Config(mixin(q{flags} ~ op ~ q{other.flags})); + } /// ditto + Config opOpAssign(string op)(Config other) + if (is(typeof(mixin(q{flags} ~ op ~ q{=other.flags})))) + { + return Config(mixin(q{flags} ~ op ~ q{=other.flags})); } /// ditto version (StdDdoc) @@ -2151,6 +2162,16 @@ struct Config } } +// https://issues.dlang.org/show_bug.cgi?id=22125 +@safe unittest +{ + Config c = Config.retainStdin; + c |= Config.retainStdout; + c |= Config.retainStderr; + c &= ~Config.retainStderr; + assert(c == (Config.retainStdin | Config.retainStdout)); +} + /// A handle that corresponds to a spawned process. final class Pid {