From 7b34bdaddedcff540fbe48a02821f4290c55e99e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Mon, 6 Apr 2020 13:45:16 +0200 Subject: [PATCH] Fix compile error when naming a TaggedUnion field "move". --- source/taggedalgebraic/taggedunion.d | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/taggedalgebraic/taggedunion.d b/source/taggedalgebraic/taggedunion.d index 9c446cb..5e8591d 100644 --- a/source/taggedalgebraic/taggedunion.d +++ b/source/taggedalgebraic/taggedunion.d @@ -87,7 +87,7 @@ align(commonAlignment!(UnionKindTypes!(UnionFieldEnum!U))) struct TaggedUnion static if (isUnitType!(FieldTypes[ti])) set!(cast(Kind)ti)(); else - set!(cast(Kind)ti)(move(value)); + set!(cast(Kind)ti)(.move(value)); } void opAssign(FieldTypes[ti] value) @@ -95,7 +95,7 @@ align(commonAlignment!(UnionKindTypes!(UnionFieldEnum!U))) struct TaggedUnion static if (isUnitType!(FieldTypes[ti])) set!(cast(Kind)ti)(); else - set!(cast(Kind)ti)(move(value)); + set!(cast(Kind)ti)(.move(value)); } } @@ -211,7 +211,7 @@ align(commonAlignment!(UnionKindTypes!(UnionFieldEnum!U))) struct TaggedUnion mixin("alias "~name~"Value = value!(Kind."~name~");"); mixin("static TaggedUnion "~name~"(FieldTypes["~i.stringof~"] value)" - ~ "{ TaggedUnion tu; tu.set!(Kind."~name~")(move(value)); return tu; }"); + ~ "{ TaggedUnion tu; tu.set!(Kind."~name~")(.move(value)); return tu; }"); // TODO: define assignment operator for unique types } else { @@ -517,6 +517,11 @@ unittest { // null members should be assignable assert(val.kind == val.Kind.Null); } +unittest { // make sure field names don't conflict with function names + union U { int to; int move; int swap; } + TaggedUnion!U val; + val.setMove(1); +} enum isUnitType(T) = is(T == Void) || is(T == void) || is(T == typeof(null));