Commit graph

20477 commits

Author SHA1 Message Date
Aditya Chincholkar
dfc3d021c6
Fix #10513 - powmod is slow for ulong (#10688)
Co-authored-by: Iain Buclaw <ibuclaw@gdcproject.org>
2025-03-27 17:54:57 +08:00
Elias Batek
89f5914683
Revert "Fix #9584 - Using dirEntries and chdir() can have unwanted results (#10666)" (#10718)
This essentially reverts commit 274109b3de.
2025-03-27 16:21:21 +08:00
Inkrementator
0edef23caf
Variant segfault (#10697)
* Reference correct issue for test

* Variant: Fix Segfault on adding in wrapped AA
2025-03-26 07:14:47 +08:00
Elias Batek
b57f75d44e
Tune FreeBSD timeouts on GitHub Actions (#10708)
Currently, our FreeBSD CI tests either complete within about 11 minutes
or timeout after 60 mins – ~50 of them spent idling erroneously.

The new values are calculated as follows:
Timeout taken of DMD's "main" workflow + 5 extra minutes

- <2036516c17/.github/workflows/main.yml (L194)>
- <2036516c17/.github/workflows/main.yml (L201)>
2025-03-24 10:33:32 +08:00
Inkrementator
91af96cddb
Change documentation for reduce (#10707)
* reduce: Document Acc, Elem order in most visible place

* Reduce doesn't enforce predicates

* Reduce: Document behaviour on range with 1 elem

* Doc: Remove references to implemententation detail

Accumulator is the commonly used term for this concept.
2025-03-24 05:39:45 +08:00
Elias Batek
12f99e5fff
Remove empty line between doc comment and unittest (#10705) 2025-03-23 16:23:10 +08:00
Paul Backus
3dc8091758
Merge pull request #10703 from VPanteleev-S7/json-tohash
std.json: Add JSONValue.toHash
2025-03-22 15:42:05 -04:00
Vladimir Panteleev
6beff688d2 std.json: Add JSONValue.toHash
Allows using JSON values in sets and map keys.
2025-03-22 17:38:24 +00:00
Paul Backus
1fab9aca41
Fix #10701 - Broken link in documentation of randomUUID (#10702)
Arguments to DDoc macros must be separated by a comma and at most one
space, not spread over multiple lines.
2025-03-21 04:24:23 +08:00
Paul Backus
96ab2077c3
Merge pull request #10694 from ntrel/template-of-void
std.traits.TemplateOf doesn't return void for non-template functions
2025-03-19 13:46:51 -04:00
Nick Treleaven
2ceb13ed44 std.traits.TemplateOf doesn't return void for non-template functions #10527 2025-03-19 14:47:43 +00:00
Inkrementator
67afde4f10
Fix #9585 Add check variant alignment (#10690)
* Fix #9585 Add check `variant` alignment

There has been code that handles alignment for a long time
now, and while this module is unlikely to be touched anymore, create a
regression test so the issue can be closed.

* Apparently double is 32bit aligned on x86
2025-03-19 12:20:30 +08:00
Inkrementator
c79914db2d
Fix #10440 Use right template constraint for each (#10689)
The current contraints have been implemented in #3837 to make `each`
behave more like `foreach` and automatically destructure tuples.

I haven't publically documented this behavior because it is probably
better these days to use `bind` for that.
2025-03-19 07:14:17 +08:00
The Dlang Bot
56f8c64df4
Merge pull request #10686 from Inkrementator/hypot_complex_abs_fixes
Unify abs(Complex!T) and hypot

Signed-off-by: Iain Buclaw <ibuclaw@users.noreply.github.com>
Merged-on-behalf-of: Iain Buclaw <ibuclaw@users.noreply.github.com>
2025-03-18 13:35:41 +01:00
Inkrementator
5329c10555 Optimization: Use u*u over u^^2 for better inlining 2025-03-18 00:19:13 +01:00
Inkrementator
006b1ca936 Logic: Move (huge,tiny) test up, supersedes testing for 0.0 2025-03-18 00:19:11 +01:00
gulugulubing
e8a7280b5d
Remove outdated @safe bug entry from toDelegate documentation (#10672) 2025-03-18 06:36:21 +08:00
Elias Batek
b150fde4da
Improve the situation with #9881 - Use unpredictableSeed in randomUUID() (#10671) 2025-03-17 15:10:26 -07:00
Inkrementator
da127b18b8 Add regression test for #10491 2025-03-17 22:40:33 +01:00
Inkrementator
63ce5c37c0 Optimization: Move NaN-check inside branch where it is guaranteed to happen 2025-03-17 22:40:33 +01:00
Inkrementator
91aa5feead Unify hypot and abs of complex values
This ports the fixes from abs(T)(ComplexT) regarding NaN and skipping
potentially inaccuracy inducing mathematical no-ops when one arg is 0 to
hypot. Both functions do the same thing and should be deduplicated.
hypot also has some logic regarding under and overflows, and while I
don't fully understand it, it should probably not be removed for complex
numbers.
2025-03-17 22:40:31 +01:00
Aditya Chincholkar
e1d9d0208b
Fix issue #10491 Complex!float.abs / hypot invalid result when argument is small (#10679) 2025-03-17 22:18:39 +08:00
Aditya Chincholkar
fd4979ab99
Fix issue #9829 std.conv.parse!(int, string) counts when doCount is false (#10674) 2025-03-17 22:15:40 +08:00
Aditya Chincholkar
271ae6219d
Fix #10577 - [std.math] std.math.algebraic.cbrt is not pure (#10670) 2025-03-16 07:24:13 +08:00
Elias Batek
13279b8594
Add additional tests to std.conv (#10673) 2025-03-15 16:28:45 +08:00
Elias Batek
264618e838
Cleanup DirIteratorImpl.__ctor (#10668) 2025-03-15 08:41:33 +08:00
Elias Batek
1e70ab9301
Remove range support from DirIteratorImpl.__ctor (#10667)
Was unused, untested and potentially broken.
2025-03-13 15:56:08 +08:00
Elias Batek
274109b3de
Fix #9584 - Using dirEntries and chdir() can have unwanted results (#10666)
Co-authored-by: GallaFrancesco <francesco.galla3@gmail.com>
Co-authored-by: Elias Batek <15967408+0xEAB@users.noreply.github.com>
2025-03-12 16:14:48 +08:00
Paul Backus
a7e90e9bf3
Merge pull request #10665 from pbackus/fix-gh-10540
sumtype: rename 'degrees' to 'value' in example
2025-03-11 11:07:14 -04:00
Paul Backus
613ec088e4 sumtype: rename 'degrees' to 'value' in example
Strictly speaking, the Kelvin scale is not measured in degrees, so the
previous name was incorrect. Changing it in all cases preserves
consistency.

Fixes #10540
2025-03-11 10:33:32 -04:00
Jonathan M Davis
f243f645ad
Add isType to phobos.sys.traits. (#10663)
This is a simple and straightforward trait. It just says whether the
template argument is a type or not. It has the same functionality as the
trait with the same name in std.traits. However, the implementation is
different. The std.traits version just has an alias overload and uses an
is expression, whereas it seemed like it would probably be more
efficient to split the trait into two and have the kind of argument
determine the result, since the compiler has to go through the work of
deciding whether the argument matches already, though I don't know
enough about the compiler implementation to know for sure that this
implementation is better. Either way, it can be changed later if it's
determined that the std.traits implementation is better.
2025-03-08 21:32:45 +08:00
Paul Backus
3f990a7e25
Merge pull request #10650 from pbackus/sumtype-proc-api
Procedural API for SumType
2025-03-03 23:19:20 -05:00
Paul Backus
4a91ed7033 stdio: add readfln and File.readfln
Compared to readf, these functions provide a less error-prone way to
read a single line of formatted input.

Fixes #10370
2025-03-03 03:47:52 +01:00
Nicolò Monaldini
0d724aa0c8
Fix %*s handling by formattedRead() (#10654) 2025-03-03 06:59:08 +08:00
dhawal543
4b39202045
Fix #10565: Prevent negative zero when multiplying BigInt zero by neg… (#10655) 2025-03-02 21:08:03 +08:00
Paul Backus
6722d0a50b
Add std.conv.bitCast (#10651)
* Add std.conv.bitCast

This helper function is a more readable alternative to the traditional
pointer-cast-based syntax for reinterpreting casts.

The name bitCast is used for this operation in several other languages,
including C++ [1], Swift [2], C# [3], Zig [4], and LLVM IR [5].

[1] https://en.cppreference.com/w/cpp/numeric/bit_cast
[2] https://developer.apple.com/documentation/swift/unsafebitcast(_:to:)
[3] https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.unsafe.bitcast
[4] https://ziglang.org/documentation/0.10.0/#bitCast
[5] https://llvm.org/docs/LangRef.html#bitcast-to-instruction

* Add changelog entry for std.conv.bitCast
2025-02-28 13:54:10 -08:00
Paul Backus
1d3177ff2a sumtype: prevent ambiguity in failedGetMessage 2025-02-27 10:01:43 -05:00
Paul Backus
03f7dbab9d sumtype: make has!T.checkType helper private 2025-02-27 09:49:29 -05:00
Paul Backus
4e51fdcd84 sumtype: add changelog entry for has, get, tryGet 2025-02-25 09:52:18 -05:00
Paul Backus
7e34f06d83 sumtype: extract common code from get and tryGet 2025-02-24 14:26:39 -05:00
Paul Backus
688ecf2089 sumtype: add tryGet!T, a throwing version of get!T 2025-02-24 14:25:51 -05:00
Paul Backus
756e50dde1 sumtype: add get!T to access a SumType's value 2025-02-24 14:24:47 -05:00
Paul Backus
391ff50015 sumtype: add has!T to check type of SumType value 2025-02-24 14:23:11 -05:00
Adam Wilson
ab9b5cb48d
Add the ODBC 4.0 modules based on ImportC and deprecate the old ODBC 3.5 modules. (#10649) 2025-02-24 22:18:19 +08:00
Paul Backus
fe64ac592b Rename SumType.get to getByIndex 2025-02-23 20:32:07 -05:00
Paul Backus
40daf61851
sumtype: fix canMatch for non-copyable ref return (#10648)
Handlers that return a non-copyable value by reference are now capable
of successfully matching.

Fixes #10647
2025-02-24 06:12:00 +08:00
Inkrementator
3a8f31acbd
Fix #9811 Remove const from Tuple.toString (#10646)
Now, member structs won't become const due to transitiveness and the
code in `std.format` can choose (erroneously) non-cost toString()
functions of member structs.

An expert has to decide whether this is worth the breaking change. Now,
code that uses `const` tuples and calls toString directly on them will
break. Alternatively, we could use
[Template this parameters](https://dlang.org/spec/template.html#template_this_parameter).

That way, we get a template parameter with the real type of this. Then we can
cast away constness of `this` when we now for certain that it isn't,
since `is(T != typeof(this))` (where T is the template this parameter).
Of course, this implies making toString `@trusted` too.

This might also lead to unforeseen bugs when `const` is cast away but
the member objects are actually const. I'm not sure how this works.

Fwiw, currently std.format and `std.conv: to` already intercepts const tuples,
thus it at least won't call toString directly. The breaking change will
only effect code that calls toString on const tuples directly.

That's why I have added non-prescritive tests. If something in
std.format changes, they'll be alerted and can then decide whether to
change the tests or whether this module also needs work, in case this
would lead a bigger breaking change.

Followup to #10645.
2025-02-22 09:25:20 +08:00
Inkrementator
310bd9b193
Tuple toString (#10645)
* Use formattedWrite instead of format

* Remove workaround for shared objects in formattedWrite

The tests are still working. Is it safe to assume that the workaround
would've only been merged if there is a test-case checking it?

* Remove sharedToString workaround

For shared classes, it prints the mangled name, for struct pointers it will
print the adress.

This version of Tuple.toString won't work anymore in @safe code in
general if the tuple contains anything descended from Object. I think
this is correct even if a breaking change, since dealing with this issue
should be the responsibility of the caller.

* Comment to existing code

* Reference the bug that a unit test exemplifies
2025-02-21 07:18:51 +08:00
Inkrementator
b48a877814
Fix chain potentially mutating a stale object (#10643)
The constructor of the result of std.range.chain copies it's input tuple
and then has to check which of the input-ranges in the first non-empty
one. The member function empty is not guaranteed to be const, filter is
probably the most prominent function that has to be "primed". On the
first call to empty(), filter will try to advance all it's input ranges
to the first element that matches the predicate.
For ranges with full value semantics, using the old input object instead
of the new internal buffer means that the work of priming is done twice.
If any ranges have reference semantics, the references gets advances,
but the value-semantic parts of the range-composition gets reset.

This fixes #10561 and #9877
2025-02-20 06:23:34 +08:00
Inkrementator
f52a44d401
Fix Bugzilla Issue 24818 Sumtype with single-type wastes space (#10642)
* Fix Bugzilla Issue 24818 Sumtype with single-type wastes space

* Move unittest to correct position

* Annotate unittest with @safe
2025-02-18 19:49:59 -08:00