Thread overview | |||||
---|---|---|---|---|---|
|
July 08, 2019 [Issue 20030] Variant concat of char and string doesn't work | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20030 shove <shove@163.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |shove@163.com --- Comment #1 from shove <shove@163.com> --- (In reply to Simen Kjaeraas from comment #0) > The following code throws a VariantException complaining about different > types (char and immutable(char)[]): > > unittest { > import std.variant; > Variant v = ""; > v ~= 'a'; > } > > It's correct in some ways, but clearly a more useful behavior would be to concat the string and char and move on. This shouldn't be a bug. Variant's design has strict restrictions on type qualifiers, because string = immutable (char) [], so the ~ operator restricts char. v ~= cast (immutable char)'a'; is possible because its qualifier is consistent. For these limitations, you can see the unittest: https://github.com/dlang/phobos/blob/master/std/variant.d#L2655 There are many anomaly collection behaviors for qualifier inconsistencies. I don't know whether it was intentionally designed to do this, or because it was temporarily done for the sake of simplicity. I think, if there are no other factors, it would be better to fix the variant implementation and remove these restrictions. -- |
December 12, 2019 [Issue 20030] Variant concat of char and string doesn't work | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20030 berni44 <bugzilla@d-ecke.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla@d-ecke.de OS|Windows |All -- |
December 17, 2022 [Issue 20030] Variant concat of char and string doesn't work | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20030 Iain Buclaw <ibuclaw@gdcproject.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P1 |P3 -- |
Copyright © 1999-2021 by the D Language Foundation