Commit graph

19 commits

Author SHA1 Message Date
Paul Backus
d9d104c9bc Fix issue 22901 - Can't construct inout SumType
The template constraint is needed to ensure that the inout constructor
overload is only considered when it is an exact match, without qualifier
conversions.

Without the constraint, a constructor call such as

    const(SumType!(int[]))([1, 2, 3])

...would be ambiguous, since it would match both the const constructor
overload and the inout constructor overload at the "match with qualifier
conversion" level.
2022-03-20 14:57:40 -04:00
canopyofstars
668d43c5df Fix 22851 - Add source reference to std.sumtype
Add `Source: $(PHOBOSSRC std/sumtype.d)` to `std.sumtype's` module documentation.
2022-03-06 03:34:35 +00:00
Paul Backus
a1f8c4c070 Revert "sumtype: work around issue 21975 in isSumType"
This reverts commit 2de68340ae.
2022-03-01 15:09:30 +00:00
Paul Backus
2de68340ae sumtype: work around issue 21975 in isSumType
isSumType!T now evaluates to true instead of false when T is a templated
struct type that implicitly converts to a SumType via alias this.
2022-02-27 23:15:28 +00:00
Paul Backus
5e3c4af308 sumtype: add example of memory corruption to docs
This makes it clearer why SumType.opAssign must sometimes be @system.
2022-02-23 18:30:07 +00:00
Paul Backus
5ca44b74a5 Fix Issue 22572 - Cannot define SumType over immutable struct with Nullable
Previously, SumType incorrectly assumed that all members of an
inout(SumType) must themselves be inout-qualified. However, this is not
the case when one of those member types is declared as immutable, since
the qualifier combination `immutable inout` collapses to just
`immutable`.

Attempting to copy an immutable member type as though it were inout
caused matching to fail in SumType's copy constructor, due to the
following (gagged) error:

  Error: `inout` on `return` means `inout` must be on a parameter as
  well for `pure nothrow @nogc @safe inout(Storage)(ref immutable(Value)
  value)`
2022-02-09 22:50:10 +00:00
wolframw
cab079a276 sumtype: remove redundant "See Also" in tryMatch documentation 2021-12-22 21:24:30 +00:00
Paul Backus
5ac515b52c Fix Issue 22117 - Can't store scope pointer in a SumType
Previously, the assignment of the local variable 'newStorage' to the
longer-lived member variable 'storage' caused scope inference to
(correctly) fail.

newStorage was necessary to work around issues 21229 and 22118. Since
those issues have been fixed, newStorage can be safely removed.
2021-08-23 21:52:40 -04:00
Paul Backus
f96f8046d9 Fix Issue 22225 - SumType: Some assignments should be able to execute in safe code 2021-08-19 23:07:12 +00:00
Paul Backus
32f32525bf Fix issue 22077 - std.sumtype support for copy constructors is incomplete
Previously, SumType would define the wrong set of constructors for types
whose copyability varies depending on their mutability--a situation that
was impossible with postblits, but is now possible with copy
constructors.
2021-08-12 03:23:11 +00:00
Dennis
1cb398ffcd
Disable non-@nogc unittest in -betterC (#8163) 2021-07-13 08:55:35 +08:00
berni44
b2019ebab0 Narrow imports of std.math in the rest of phobos. 2021-04-21 03:00:57 +02:00
Atila Neves
7407ce93cd Revert "Fix Issue 21731 - SumType should provide convenient access to the typ…" 2021-03-26 22:01:23 +01:00
The Dlang Bot
5dd4446c80
Merge pull request #7886 from pbackus/sumtype-type-index
Fix Issue 21731 - SumType should provide convenient access to the typ…
merged-on-behalf-of: Steven Schveighoffer <schveiguy@users.noreply.github.com>
2021-03-20 15:10:59 +01:00
Paul Backus
e1baa9b6a0 Reword documentation for SumType.typeIndex
The new wording describes the result without implying anything about the
implementation.
2021-03-20 00:19:28 -04:00
Paul Backus
50c7945236 Fix Issue 21731 - SumType should provide convenient access to the type index 2021-03-19 17:12:27 -04:00
berni44
6f2a0934a7 Adapt imports of std.format to new structure of std.format. 2021-03-19 13:22:00 +01:00
Paul Backus
56bc37c8e5 Fix Issue 21708 - SumType.opEquals gives confusing error message 2021-03-13 23:28:48 +01:00
Paul Backus
51a70ee267
Add sumtype to Phobos (#7702)
Add sumtype to Phobos
merged-on-behalf-of: unknown
2021-03-05 12:41:34 +01:00