Commit graph

20454 commits

Author SHA1 Message Date
Richard (Rikki) Andrew Cattermole
c64232d813
Fix #10713 - std.format string positions affect all further format specifiers (#10714) 2025-03-25 16:10:34 +08:00
Martin Kinkelin
b41bcd93df
std.experimental.allocator.building_blocks.allocator_list: Fix unittests on macOS arm64 (#10704)
Otherwise hitting a consistently failing assertion for LDC CI.
2025-03-23 07:51:23 +08:00
Paul Backus
d4c9efef15
Merge pull request #10700 from ibuclaw/numeric_ieee_link
std.numeric: Fix IEEE typo in link
2025-03-20 13:44:18 -04:00
Iain Buclaw
0f3185e954 std.numeric: Fix IEEE typo in link 2025-03-20 15:11:25 +01:00
Steven Schveighoffer
79cbde1ab6
Fix #10680 - Instead of passing receiver into the conversion function, (#10684)
just return the value and assign it to the receiver. Renamed the
conversion function and also cleaned up all the `typeof` calls, which
were very verbose.
2025-03-18 06:38:36 +08:00
Martin Kinkelin
cafe864533
std.json: Avoid setting union members, set the whole union instead (#10683)
To work around https://github.com/dlang/dmd/issues/20675.
2025-03-17 22:24:14 +08:00
Dennis Korpel
0faae92d62 Merge remote-tracking branch 'upstream/master' into stable 2025-03-09 17:10:29 +01: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
Inkrementator
d4dd391123
Remove obsolete workaround (#10641)
For resolved bugzilla issue 15777
2025-02-19 06:42:13 +08:00
Vladimir Panteleev
bb0c2953dd std.process: Fix memory corruption in exec functions
Fixes issue #10639.
2025-02-18 13:24:48 +01:00
Nick Treleaven
ea28abfadb [std.container DList docs] Fix time complexity of insertFront etc
See https://forum.dlang.org/post/vkubcdpniiseeuxvdvim@forum.dlang.org
2025-02-17 17:48:13 +01:00
Robert Schadek
ffb70c5580
Name argument if data conversion fails getopt (#10593)
Fixes #9662

whitespace
2025-02-07 10:19:20 -08:00
Jonathan M Davis
b085fd70e0
Add phobos.sys.traits.hasIndirections. (#10634)
It does the same thing as the std.traits version. They both alias the
one in druntime. However, the documentaton and tests have been beefed up
a bit.

I also added assertWithQualifiers as a private test helper, which it may
make sense to add later as a public test helper somewhere, but we don't
currently have any module or package for that sort of thing, so for now,
it's private. Some of the existing tests should probably also be
refactored to use it, but I'm not worrying about that as part of these
changes.
2025-02-07 08:20:22 -08:00
Paul Backus
fcffbc0d97
Merge pull request #10625 from 0xEAB/ctEval
Fix #10023 - Add `ctEval` to Phobos
2025-02-07 10:29:04 -05:00
Elias Batek
4e2156110a
Address pbackus’ review
Co-authored-by: Paul Backus <snarwin@gmail.com>
2025-02-03 23:03:49 +01:00
Paul Backus
c5d074b12e Refactor: access SumType value by index, not type
Previously, code that already knew the desired index was forced to
compute a type to pass to get!T or memberName!T, just for get!T or
memberName!T to turn that type back into an index. Removing this
unnecessary round trip simplifies the code.

Additionally, since memberName is no longer dependent on SumType.Types,
it can be moved to module scope, and its instantiations can be shared
across different SumType instances.
2025-02-03 00:46:36 +01:00
Martin Kinkelin
9971927d53
GHA main: Add Alpine Linux job, to CI-test musl libc (#10632) 2025-01-28 03:00:59 +01:00
Elias Batek
99602a5d44 Make unpredictableSeed use BCryptGenRandom (CNG) on Windows 2025-01-26 01:56:31 +01:00
Elias Batek
f2c49d368b Make unpredictableSeed use getrandom (syscall) on Linux 2025-01-25 02:52:05 +01:00
Elias Batek
5b373178c7
Fix unittests of toDelegate (#10631)
As discovered by @Bolpat:
<https://github.com/dlang/phobos/pull/10599#discussion_r1925219756>
2025-01-25 06:41:52 +08:00
Kymorphia, PBC
488ea697a4
RandomFiniteAssignable incorrectly referenced as RandomAccessAssignable in ddoc index (#10630) 2025-01-24 06:11:51 +08:00
Dennis
d4a1354f31
Remove flakey stopwatch test (#10628) 2025-01-22 05:00:11 +08:00
Iain Buclaw
7be45e8e01 unittest: Don't run x87 log2 test on 64-bit real targets 2025-01-19 15:45:14 +01:00
IchorDev
a4d516a6d1
Docs: fix 'for signed integrals' appearing twice (#10626) 2025-01-19 19:19:11 +08:00
Elias Batek
2631a8b145 Fix #10023 - Add ctEval to Phobos 2025-01-19 07:08:37 +01:00
John Colvin
bea3184479
Add low-overhead InPlaceAppender (#8789)
- Internal for now.
- Previously known as `FixedAppender` (during development).

Co-authored-by: Elias Batek <0xEAB@users.noreply.github.com>
2025-01-19 08:03:43 +08:00
Elias Batek
1b242048c9 Fix #10605 - Make File.byLine usable in @safe contexts 2025-01-17 18:51:08 +01:00
Nick Treleaven
5f39350c48
Fix #10538 - Cannot swap a std.typecons.Tuple (#8864)
* Fix #10538 - Cannot swap a std.typecons.Tuple

Co-authored-by: Elias Batek <0xEAB@users.noreply.github.com>

* De-optimize `opAssign` of `std.typecons.Tuple`

---------

Co-authored-by: Elias Batek <0xEAB@users.noreply.github.com>
Co-authored-by: Elias Batek <desisma@heidel.beer>
2025-01-17 15:13:37 +08:00
Dennis
336bed6d8f
Merge pull request #10621 from 0xEAB/thewilsonator-patch-1
Fix self assignment for dlang/dmd#20696
2025-01-14 10:17:13 +01:00
Elias Batek
475e5c69d6 2025-01-14 02:54:28 +01:00
Dennis Korpel
7433715cf6 Fix reference to 'samples' folder 2025-01-13 23:53:54 +01:00