|
3 | 3 |
|
4 | 4 | using System.Collections.Generic;
|
5 | 5 | using System.Linq;
|
6 |
| -using System.Numerics; |
7 | 6 | using Microsoft.PowerFx.Core.App.ErrorContainers;
|
8 | 7 | using Microsoft.PowerFx.Core.Binding;
|
9 | 8 | using Microsoft.PowerFx.Core.Entities;
|
@@ -49,7 +48,7 @@ public override bool TryGetTypeForArgSuggestionAt(int argIndex, out DType type)
|
49 | 48 | return base.TryGetTypeForArgSuggestionAt(argIndex, out type);
|
50 | 49 | }
|
51 | 50 |
|
52 |
| - public RemoveBaseFunction(int arityMax, params DType[] paramTypes) |
| 51 | + public RemoveBaseFunction(int arityMax, params DType[] paramTypes) |
53 | 52 | : base("Remove", TexlStrings.AboutRemove, FunctionCategories.Behavior, DType.EmptyTable, 0, 2, arityMax, paramTypes)
|
54 | 53 | {
|
55 | 54 | }
|
@@ -99,6 +98,14 @@ public override bool IsAsyncInvocation(CallNode callNode, TexlBinding binding)
|
99 | 98 |
|
100 | 99 | return Arg0RequiresAsync(callNode, binding);
|
101 | 100 | }
|
| 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 | + } |
102 | 109 | }
|
103 | 110 |
|
104 | 111 | // Remove(collection:*[], item1:![], item2:![], ..., ["All"])
|
@@ -167,10 +174,7 @@ public override bool CheckTypes(CheckTypesContext context, TexlNode[] args, DTyp
|
167 | 174 |
|
168 | 175 | if (!argType.IsRecord)
|
169 | 176 | {
|
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)) |
174 | 178 | {
|
175 | 179 | continue;
|
176 | 180 | }
|
@@ -368,9 +372,7 @@ public override bool CheckTypes(CheckTypesContext context, TexlNode[] args, DTyp
|
368 | 372 | }
|
369 | 373 | }
|
370 | 374 |
|
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])) |
374 | 376 | {
|
375 | 377 | fValid = false;
|
376 | 378 | errors.EnsureError(DocumentErrorSeverity.Severe, args[2], TexlStrings.ErrRemoveAllArg);
|
|
0 commit comments