Commit graph

16625 commits

Author SHA1 Message Date
Nathan Sashihara
ebdc9a8975 Alter AMD RDAND bug detection to reduce bias against -1 in unpredictableSeed
Before this PR if RDRAND was working the chance of unpredictableSeed
returning -1 was 2^^-64 instead of the expected 2^^-32. Now the chance
is 2^^-32 - 2^^-64 + 2^^-96.
2021-10-15 02:54:11 +00:00
Petar Kirov
5cf43c23ff Delete outdated comment
As per https://github.com/dlang/phobos/pull/8276#discussion_r729390034.
2021-10-15 00:14:13 +00:00
MoonlightSentinel
c95d013d8e Fix 22370 - Accept noreturn callables in std.concurrency.spawn[Linked]
`spawn[Linked]` required the passed callable to return `void`. This is
unecessarily strict because both `void` and `noreturn` imply that no
actual value will be returned by the callable.
2021-10-14 18:49:49 +00:00
Per Nordlöw
0812f7a4e0 Avoid string concatenations in put() calls to avoid GC allocations 2021-10-14 18:26:14 +00:00
MoonlightSentinel
bb2b31f892 Fix 22383 - Reject noreturn[] as an autodecodable string
`noreturn[]` does not contain characters and hence is not subject to
autodecoding. The previous behaviour caused the range primitives (`put`,
...) to call into autodecoding related functions which couldn't handle
`noreturn[]`.
That error caused `isInputRange!(noreturn[])` to yield false.
2021-10-14 17:23:16 +00:00
MoonlightSentinel
fc500c2ccd Fix 22386 - Omit unreachable throw in assertThrown with noreturn value
The lazy value will throw or never return at all and hence never
reach the additional throw statement.
2021-10-14 15:40:57 +00:00
Ate Eskola
dadfd00b5e Added a comment about the invariant of respecting stripped qualifiers. 2021-10-14 16:14:59 +03:00
Razvan Nitu
4130a1176c
Merge pull request #8270 from MoonlightSentinel/noreturn/castswitch
Fix 22384 - Treat noreturn handlers like void in castSwitch
2021-10-14 11:49:28 +03:00
Andrei Alexandrescu
4b3e8a9214
Merge pull request #8045 from andralex/staticSort
Improve staticSort by using some ctfe instead of template recursion
2021-10-13 17:45:47 -04:00
Andrei Alexandrescu
31ca51e9c1 Improve staticSort by using some ctfe instead of template recursion 2021-10-13 16:32:20 -04:00
Ate Eskola
769299f70b Fix issue 21022 - only should work with qualifiers 2021-10-13 21:32:33 +03:00
Razvan Nitu
d8e91d147c
Merge pull request #8269 from dukc/simplifyOnly
Swapped out custom empty `only` for a simpler empty array.
2021-10-13 21:29:18 +03:00
MoonlightSentinel
3e70aac3ae
Fix 22384 - Treat noreturn handlers like void in castSwitch
The previous check assumed that non-`void` return implies a returned
value - which obviously does not apply for `noreturn`.
Further code then assumed that `void` handlers should throw an exception
and hence threw an error when it didn't throw.
2021-10-13 17:35:11 +02:00
Ate Eskola
dc15745a4a Swapped out custom empty only for a simpler empty array. 2021-10-13 17:59:56 +03:00
MoonlightSentinel
4cf70e6c43
Fix 22369 - Omit unreachable statements in std.concurrency
Instantiating these templates with noreturn values / callbacks causes
the versioned statements to become unreachable.
2021-10-13 15:26:14 +02:00
Razvan Nitu
2f5008ab89
Merge pull request #8263 from adamdruppe/bug_22359
Fix issue #22359 - joiner over an empty class range liable to segfault
2021-10-09 12:17:53 +03:00
MoonlightSentinel
b612caa162
Fix 22368 - has[Unshared]Aliasing fails to instantiate for noreturn
The problem was that `noreturn` matched the special case for `Rebindable`
because the bottom type is implicitly convertible to any type.
2021-10-08 19:23:04 +02:00
MoonlightSentinel
1c8047bc6d Fix 22364 - Omit unreachable return in collectException[Msg]...
...when instantiated with `noreturn`.

DMD is able to determine that a lazy `noreturn` expression will interrupt
the normal control flow (throw / halt / ...) s.t. it never reaches the
`return`.
2021-10-08 11:49:48 +00:00
Razvan Nitu
12b43809a3
Merge pull request #8162 from DoctorNoobingstoneIPresume/210709_std_container_array_Payload_DefaultConstruct_01h
std.container.Array: Payload "default constructor" simplifies Array.
2021-10-08 14:46:56 +03:00
Adam D. Ruppe
ff6920bd8a Fix issue #22359 - joiner over an empty forward range object liable to segfault
If you pass it a range of class-based ranges, the initialization to
`typeof(_current).init` will be `null`. Calling the `save` method
on `null` will naturally be a memory violation. This generic check
will handle null without harming any other type since save of any
init value will be another init value.
2021-10-07 10:34:35 -04:00
Razvan Nitu
14b750f0bc
Merge pull request #8256 from pbackus/fix-19544
Fix issue 19544 - Can't call inputRangeObject on ranges not supported by …
2021-10-05 12:32:57 +03:00
Paul Backus
3ad8dbd41c Check return value of 'open' in std.process test
Previously, if this call to 'open' failed, it would result in a spurious
test failure. Now, it instead causes the test to be skipped.

Possibly related to https://issues.dlang.org/show_bug.cgi?id=22350
2021-10-03 22:35:00 +00:00
Paul Backus
2cb2d6cd67 Refactor std.traits.EnumMembers 2021-10-03 22:13:35 +00:00
Paul Backus
b7ef267ab4 Replace FieldProxy with @property ref functions
This simplifies the code and removes the need for a separate
version (StdDdoc) block.
2021-10-03 08:15:39 +00:00
Paul Backus
e1672cfb8d Use a custom exception type in InputRangeObject
This allows users to distinguish between exceptions thrown by
InputRangeObject itself and exceptions thrown by the wrapped range.
2021-10-02 17:27:03 -04:00
lucica28
232ca53126
Fix issue 21507 - added precision for function SysTime.toIsoExtString (#8255)
Fix issue 21507 - added precision for function SysTime.toIsoExtString

Signed-off-by: Petar Kirov <PetarKirov@users.noreply.github.com>
Signed-off-by: Razvan Nitu <RazvanN7@users.noreply.github.com>
Merged-on-behalf-of: Razvan Nitu <RazvanN7@users.noreply.github.com>
2021-09-30 06:50:28 +00:00
Paul Backus
d15e19fc44 Fix issue 19544 - Can't call inputRangeObject on ranges not supported by moveFront
The range algorithms moveFront, moveBack, and moveAt do not accept all
valid input ranges, bidirectional ranges, and random-access ranges,
respectively. Their inclusion as methods of the InputRange,
BidirectionalRange, and RandomAccessFinite interfaces previously caused
InputRangeObject, which implements those interfaces, to fail to compile
when instantiated with certain valid input, bidirectional, and
random-access ranges.

These methods should not have been included in their respective
interfaces to begin with, but removing them now would break existing
code. Instead, as a workaround, InputRangeObject now implements these
methods by throwing an exception if the wrapped range does not support
them.
2021-09-29 20:35:30 -04:00
Hiroki Noda
e9a5297836 Fix Issue 22340 - totalCPUs may not return accurate number of CPUs
bugzilla url: https://issues.dlang.org/show_bug.cgi?id=22340
2021-09-28 12:13:56 +00:00
Razvan Nitu
0225bed3c2
Merge pull request #8252 from DoctorNoobingstoneIPresume/210924_std_typecons_refCounted_UT_01h
refCounted: unittest now also checks object destruction.
2021-09-27 13:03:28 +03:00
DoctorNoobingstoneIPresume
6b05400fba std.container.Array: Payload.reserve re-used, object leak fixed.
This is another attempt to re-use the code in `Payload.reserve` --
similar to https://github.com/dlang/phobos/pull/8143 (commit 0b7bf8dc):
"std.container.Array: Simplify implementation of length (by calling reserve).".

Additionally, `Array`'s variadic constructor is now safer:

  If `emplace`-ing an element fails, successfully `emplace`-d elements are now destroyed.

  Example:

  ```
    auto a = Array!S (S(0), S(1), S(2), S(3));

    // If emplace-ing a[2] (as a copy of S(2)) fails:
    //   - pre-existing behaviour: a[1] and a[0] were not destroyed (bad);
    //   - new behaviour:          a[1] and a[0] are      destroyed (good).
  ```

  A corresponding `unittest` has been added (`S.s_nDestroyed == S.s_nConstructed`):
    When such a failure (`Exception`) is caught, there should be no leaked objects.

  Implementation:
    Previously:
      - the `Payload` `length` used to be increased only once,
        after having successfully `emplace`-d all elements,
        thus incorrectly tracking the number of `emplace`-d elements during the loop
        (but correctly tracking it after the loop -- iff the entire loop succeeded).
    Now:
      - the `Payload` `length` is incremented multiple times,
        at each step i.e. after having successfully `emplace`-d each element,
        thus correctly tracking the number of `emplace`-d elements during the loop.
    Note:
      When the constructor fails, the corresponding destructor is not run.
      But the destructors for successfully constructed sub-objects are run;
      in this case, the destructor for the `_data` sub-object is run --
      and it is this destructor which destroys the successfully emplaced elements
      (iff they have been correctly tracked).
2021-09-27 02:23:14 +03:00
DoctorNoobingstoneIPresume
eb66705762 refCounted: unittest now also checks object destruction..
One of the `unittest`'s has been modified to also check that
a `File` object managed via `RefCounted!File` handles is deleted
when its last handle is destroyed;
2021-09-27 02:19:34 +03:00
Tobias Pankrath
30aabd8b9c Mentions type in error message for missing opPostMove 2021-09-26 12:54:34 +00:00
Razvan Nitu
c59a711bf1
Merge pull request #8253 from nordlow/better-searchPathFor
Improve searchPathFor
2021-09-26 11:14:37 +03:00
Per Nordlöw
52304683d7 Improve searchPathFor 2021-09-25 01:47:13 +02:00
Per Nordlöw
46d416fa9d Qualify some function parameters under std.format as const to reduce template bloat 2021-09-22 23:12:15 +00:00
Razvan Nitu
94a27083ae
Merge pull request #8246 from jrfondren/fix-20554
Fix issue 20554 - std.algorithm.searching.all 's static assert produc…
2021-09-22 11:11:51 +03:00
Julian Fondren
dc2bf7901f Fix issue 20554 - std.algorithm.searching.all 's static assert produces a garbled error message 2021-09-21 20:25:26 -05:00
Paul Backus
1984e8d2a9 Fix Issue 22325 - ReplaceType fails on templated type instantiated with void-returning function
Previously, when recursing into a type's template arguments,
ReplaceTypeUnless would mistakenly attempt to evaluate a template alias
parameter as an expression. In cases where the alias parameter was not a
valid expression or could not be evaluated at compile time, this caused
a compilation failure; in other cases, it caused ReplaceTypeUnless to
give an incorrect result.

This change makes ReplaceTypeUnless correctly treat template alias
parameters as aliases.
2021-09-20 21:42:31 +00:00
Julian Fondren
3bf975041f indent multiline param description 2021-09-17 04:20:30 -05:00
Julian Fondren
ea5726f9f4 std.algorithm.sorting: fix typo and related texts 2021-09-17 04:09:34 -05:00
Martin Kinkelin
d0bf92cab7 std.typecons: Minimize redundant template declarations/instantiations wrt. Tuple
While glancing over the Tuple template, I've noticed that it uses the
anti-pattern of nested template declarations *not* depending on the
outer Tuple template parameters.
2021-09-17 04:38:55 +00:00
RazvanN7
3e7e0393e8 Re-add std.traits.Fields test with interface 2021-09-15 13:02:59 +00:00
RazvanN7
044b4a1b02 Temporarily comment one test in traits to be able to graciously fix druntime implementation 2021-09-15 09:35:04 +00:00
Per Nordlöw
6333fe3206 Replace template AliasThisTypeOf with inlined calls to __traits 2021-09-15 08:40:39 +00:00
Manu Evans
b86bb94ab9
Alias traits from druntime (#7148)
Alias traits from druntime

Signed-off-by: Nicholas Wilson <thewilsonator@users.noreply.github.com>
Signed-off-by: Eduard Staniloiu <edi33416@users.noreply.github.com>
Signed-off-by: Razvan Nitu <RazvanN7@users.noreply.github.com>
Merged-on-behalf-of: Razvan Nitu <RazvanN7@users.noreply.github.com>
2021-09-15 07:38:59 +00:00
Ate Eskola
ee836dd748 Completed attribute lithany on sameTail and sameHead 2021-09-15 03:09:09 +00:00
The Dlang Bot
139a227da5
Merge pull request #8236 from MartinNowak/merge_stable
merge stable

Signed-off-by: Razvan Nitu <RazvanN7@users.noreply.github.com>
Merged-on-behalf-of: Razvan Nitu <RazvanN7@users.noreply.github.com>
2021-09-14 08:55:03 +00:00
RazvanN7
3d54a964fa Annotate unittest with @safe 2021-09-13 16:00:38 +03:00
RazvanN7
6eb14972ad Fix Issue 22301 - Only use from if a packet was actually received 2021-09-13 14:02:55 +03:00
Sebastien Alaiwan
6ee8dc52fe Only use 'from' if a packet was actually received
This fixes a systematic assertion error when trying to receiveFrom a
non-blocking UDP socket. In this case, 'from.addressFamily' is equal to UNSPEC,
eventually failing the comparison and crashing the program.

This adds the corresponding unit test.
2021-09-13 14:00:41 +03:00