Closed andrey-zherikov closed 7 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
3d1e8b2
) 99.22% compared to head (e5bb105
) 99.23%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
struct A
{
int[] arr;
}
immutable one = SubCommand!A(A([1]));
SubCommand!A mut;
mut = one;
mut.match!(_ => _.arr[0] = 2);
assert(one.match!(_ => _.arr[0]) == 2); // Successfully modified an immutable object!
Still have to investigate if it’s a SubCommand
’s fault or SumType
’s.
Still have to investigate if it’s a
SubCommand
’s fault orSumType
’s
It seems also related to int[]
array - this fails as expected:
struct A
{
int arr;
}
immutable one = SubCommand!A(A(1));
SubCommand!A mut = one;
mut = one;
mut.match!(_ => _.arr = 2);
assert(one.match!(_ => _.arr) == 2);
struct None {}
struct S(T)
{
SumType!(None,T) a;
}
struct A
{
int[] arr;
}
immutable one = S!A.init;
immutable two = SumType!(None,A)(A([1]));
immutable three = SumType!(A,None)(A([1]));
immutable four = SumType!(A)(A([1]));
one
and two
do compile and three
and four
do not (cannot implicitly convert expression
)
Asked question on forum.
May be adding None
to SumType
was not good solution so I'd like to re-think my proposal a bit:
true
for a case with default subcommand.Default!
).init
value should be set to that default subcommand's init
.Pushed changes and confirmed that this does not compile:
struct A
{
int[] i;
}
immutable sub = SubCommand!(A)(A([1]));
Error:
Error: cannot implicitly convert expression
SubCommand(Nullable(DontCallDestructorT(SumType(Storage(A(null)), cast(ubyte)0u)), true)).this(A([1]))
of typeSubCommand!(A)
toimmutable(SubCommand!(A))
@SirNickolas Is this now good from your point of view?
Closes #80