Skip to content

Commit 2461a45

Browse files
Fix.
1 parent d1106d8 commit 2461a45

File tree

1 file changed

+11
-9
lines changed
  • src/libraries/Microsoft.PowerFx.Core/Texl

1 file changed

+11
-9
lines changed

Diff for: src/libraries/Microsoft.PowerFx.Core/Texl/Remove.cs

+11-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System.Collections.Generic;
55
using System.Linq;
6-
using System.Numerics;
76
using Microsoft.PowerFx.Core.App.ErrorContainers;
87
using Microsoft.PowerFx.Core.Binding;
98
using Microsoft.PowerFx.Core.Entities;
@@ -49,7 +48,7 @@ public override bool TryGetTypeForArgSuggestionAt(int argIndex, out DType type)
4948
return base.TryGetTypeForArgSuggestionAt(argIndex, out type);
5049
}
5150

52-
public RemoveBaseFunction(int arityMax, params DType[] paramTypes)
51+
public RemoveBaseFunction(int arityMax, params DType[] paramTypes)
5352
: base("Remove", TexlStrings.AboutRemove, FunctionCategories.Behavior, DType.EmptyTable, 0, 2, arityMax, paramTypes)
5453
{
5554
}
@@ -99,6 +98,14 @@ public override bool IsAsyncInvocation(CallNode callNode, TexlBinding binding)
9998

10099
return Arg0RequiresAsync(callNode, binding);
101100
}
101+
102+
public bool CheckEnumType(Features features, DType argType)
103+
{
104+
var enumValid = BuiltInEnums.RemoveFlagsEnum.FormulaType._type.Accepts(argType, exact: true, useLegacyDateTimeAccepts: false, usePowerFxV1CompatibilityRules: features.PowerFxV1CompatibilityRules);
105+
106+
return (features.StronglyTypedBuiltinEnums && enumValid) ||
107+
(!features.StronglyTypedBuiltinEnums && (DType.String.Accepts(argType, exact: true, useLegacyDateTimeAccepts: false, usePowerFxV1CompatibilityRules: features.PowerFxV1CompatibilityRules) || enumValid));
108+
}
102109
}
103110

104111
// Remove(collection:*[], item1:![], item2:![], ..., ["All"])
@@ -167,10 +174,7 @@ public override bool CheckTypes(CheckTypesContext context, TexlNode[] args, DTyp
167174

168175
if (!argType.IsRecord)
169176
{
170-
if (argCount >= 3 && i == argCount - 1 &&
171-
((context.Features.PowerFxV1CompatibilityRules && BuiltInEnums.RemoveFlagsEnum.FormulaType._type.Accepts(argType, exact: true, useLegacyDateTimeAccepts: false, usePowerFxV1CompatibilityRules: context.Features.PowerFxV1CompatibilityRules)) ||
172-
(!context.Features.PowerFxV1CompatibilityRules && (DType.String.Accepts(argType, exact: true, useLegacyDateTimeAccepts: false, usePowerFxV1CompatibilityRules: context.Features.PowerFxV1CompatibilityRules) ||
173-
BuiltInEnums.RemoveFlagsEnum.FormulaType._type.Accepts(argType, exact: true, useLegacyDateTimeAccepts: false, usePowerFxV1CompatibilityRules: context.Features.PowerFxV1CompatibilityRules)))))
177+
if (argCount >= 3 && i == argCount - 1 && CheckEnumType(context.Features, argType))
174178
{
175179
continue;
176180
}
@@ -368,9 +372,7 @@ public override bool CheckTypes(CheckTypesContext context, TexlNode[] args, DTyp
368372
}
369373
}
370374

371-
if (args.Length == 3 &&
372-
((context.Features.PowerFxV1CompatibilityRules && !BuiltInEnums.RemoveFlagsEnum.FormulaType._type.Accepts(argTypes[2], exact: true, useLegacyDateTimeAccepts: false, usePowerFxV1CompatibilityRules: context.Features.PowerFxV1CompatibilityRules)) ||
373-
(!context.Features.PowerFxV1CompatibilityRules && !DType.String.Accepts(argTypes[2], exact: true, useLegacyDateTimeAccepts: false, usePowerFxV1CompatibilityRules: context.Features.PowerFxV1CompatibilityRules))))
375+
if (args.Length == 3 && !CheckEnumType(context.Features, argTypes[2]))
374376
{
375377
fValid = false;
376378
errors.EnsureError(DocumentErrorSeverity.Severe, args[2], TexlStrings.ErrRemoveAllArg);

0 commit comments

Comments
 (0)