diff --git a/relnotes/lazy_verify.bug.md b/relnotes/lazy_verify.bug.md new file mode 100644 index 000000000..ac98d1ebc --- /dev/null +++ b/relnotes/lazy_verify.bug.md @@ -0,0 +1,11 @@ +### `verify` now lazily allocates on `throw`, not on call + +`ocean.core.Verify` + +`verify` used to lazily initialize a `static` exception on the first call. +However, this means that `testNoAlloc(verify(true))` could randomly fail, +depending on the order unittests are executed, +and this transitively affected all users of `verify` (that is, everything). +`verify` will now lazily allocates only on `throw`, +so `testNoAlloc(verify(true))` will always pass, +but `testNoAlloc(verify(false))` could still potentially fail. diff --git a/relnotes/suspendable-throttler-count-opsubassign.bug.md b/relnotes/suspendable-throttler-count-opsubassign.bug.md new file mode 100644 index 000000000..a7913ce39 --- /dev/null +++ b/relnotes/suspendable-throttler-count-opsubassign.bug.md @@ -0,0 +1,8 @@ +### Fix `-=` operator implementation in SuspendableThrottlerCount + +`ocean.io.model.SuspendableThrottlerCount` + +The `-=` operator overload (D1 `opSubAssign`) was inexplicably aliased +to the `add` method rather than the correct `remove`. This probably +means that no one was ever actually using the operator overload, but it +seems a good idea to fix it in any case. diff --git a/relnotes/undeprecate_fieldIdentifier.bug.md b/relnotes/undeprecate_fieldIdentifier.bug.md new file mode 100644 index 000000000..eecb0e1b2 --- /dev/null +++ b/relnotes/undeprecate_fieldIdentifier.bug.md @@ -0,0 +1,6 @@ +### Template `Identifier.fieldIdentifier` is no longer deprecated + +`ocean.meta.codegen.Identifier.fieldIdentifier` + +This template was erroneously marked as deprecated in ocean v5.0.0, but +it is still required. Using it will no longer generate a deprecation warning. diff --git a/src/ocean/core/Traits.d b/src/ocean/core/Traits.d index fa2cc53b6..820dbffc5 100644 --- a/src/ocean/core/Traits.d +++ b/src/ocean/core/Traits.d @@ -305,7 +305,7 @@ public M* GetField ( size_t i, M, T ) ( T* t ) *******************************************************************************/ -deprecated("Use ocean.meta.codegen.Identifier.identifier!(T.tupleof[i])") +deprecated("Use ocean.meta.codegen.Identifier.fieldIdentifier!(T, i)") public template FieldName ( size_t i, T ) { static if ( !isCompoundType!(T) ) diff --git a/src/ocean/core/Verify.d b/src/ocean/core/Verify.d index d573467e3..60ee23494 100644 --- a/src/ocean/core/Verify.d +++ b/src/ocean/core/Verify.d @@ -39,11 +39,11 @@ public void verify ( bool ok, lazy istring msg = "", { static SanityException exc; - if (exc is null) - exc = new SanityException(""); - if (!ok) { + if (exc is null) + exc = new SanityException(""); + exc.file = file; exc.line = line; exc.msg = msg; diff --git a/src/ocean/io/device/DirectIO.d b/src/ocean/io/device/DirectIO.d index 53ec0a940..7ccadd90c 100644 --- a/src/ocean/io/device/DirectIO.d +++ b/src/ocean/io/device/DirectIO.d @@ -574,7 +574,7 @@ public class BufferedDirectReadFile: InputStream ***************************************************************************/ - static private class DirectReadFile : File + static protected class DirectReadFile : File { override public void open (cstring path, Style style = this.ReadExisting) { diff --git a/src/ocean/io/model/SuspendableThrottlerCount.d b/src/ocean/io/model/SuspendableThrottlerCount.d index 4636bb7be..0e1e31ca6 100644 --- a/src/ocean/io/model/SuspendableThrottlerCount.d +++ b/src/ocean/io/model/SuspendableThrottlerCount.d @@ -160,7 +160,7 @@ public class SuspendableThrottlerCount : ISuspendableThrottlerCount super.throttledResume(); } - public alias add opSubAssign; + public alias remove opSubAssign; /*************************************************************************** @@ -176,6 +176,52 @@ public class SuspendableThrottlerCount : ISuspendableThrottlerCount } } +unittest +{ + import ocean.core.Test : test; + + // Helper class to allow us to test operator overloads + // without touching other parts of the class logic + static class OpsTest : SuspendableThrottlerCount + { + this () + { + size_t suspend_point = 8; + size_t resume_point = 3; + super(suspend_point, resume_point); + } + + override void inc () { this.count++; } + override void dec () { this.count--; } + + override void add (size_t n) { this.count += n; } + override void remove (size_t n) { this.count -= n; } + } + + scope ops_test = new OpsTest; + test!"=="(ops_test.length, 0); + + ops_test++; + test!"=="(ops_test.length, 1); + test(!ops_test.suspend); + test(ops_test.resume); + + ops_test += 7; + test!"=="(ops_test.length, 8); + test(ops_test.suspend); + test(!ops_test.resume); + + ops_test--; + test!"=="(ops_test.length, 7); + test(!ops_test.suspend); + test(!ops_test.resume); + + ops_test -= 4; + test!"=="(ops_test.length, 3); + test(!ops_test.suspend); + test(ops_test.resume); +} + /******************************************************************************* diff --git a/src/ocean/meta/codegen/Identifier.d b/src/ocean/meta/codegen/Identifier.d index b3b8669e5..ca99965f0 100644 --- a/src/ocean/meta/codegen/Identifier.d +++ b/src/ocean/meta/codegen/Identifier.d @@ -73,7 +73,7 @@ unittest Template to get the name of the ith member of a struct / class. Used over plain `identifier` when iterating over aggregate fields with - `.tupleof` as D1 compiler refuses to pass such field as template alias + `.tupleof` as compiler refuses to pass such field as template alias parameter. Params: @@ -85,13 +85,12 @@ unittest *******************************************************************************/ -deprecated("Use ocean.meta.codegen.identifier!(T.tupleof[i])") public template fieldIdentifier ( T, size_t i ) { enum fieldIdentifier = identifier!(T.tupleof[i]); } -deprecated unittest +unittest { static struct TestStruct { diff --git a/src/ocean/util/app/CliApp.d b/src/ocean/util/app/CliApp.d index 8f7297de8..7ec450613 100644 --- a/src/ocean/util/app/CliApp.d +++ b/src/ocean/util/app/CliApp.d @@ -36,7 +36,9 @@ import ocean.transition; abstract class CliApp : Application, IArgumentsExtExtension { - import ocean.text.Arguments : Arguments; + static import ocean.text.Arguments; + public alias ocean.text.Arguments.Arguments Arguments; + import ocean.util.app.ext.ArgumentsExt; import ocean.util.app.ext.VersionArgsExt; import ocean.util.app.ext.TaskExt;