Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 422fd0d

Browse files
committedDec 28, 2024·
PA errors fixing.
1 parent 617a7fd commit 422fd0d

File tree

2 files changed

+9
-36
lines changed
  • src
    • libraries/Microsoft.PowerFx.Core/Texl
    • tests/Microsoft.PowerFx.Interpreter.Tests.Shared/MutationScripts

2 files changed

+9
-36
lines changed
 

‎src/libraries/Microsoft.PowerFx.Core/Texl/Remove.cs

+8-35
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ public override bool CheckTypes(CheckTypesContext context, TexlNode[] args, DTyp
120120
if (!argType.IsRecord)
121121
{
122122
if (argCount >= 3 && i == argCount - 1 &&
123-
((context.Features.PowerFxV1CompatibilityRules && BuiltInEnums.RemoveFlagsEnum.FormulaType._type.Accepts(argTypes[i], exact: true, useLegacyDateTimeAccepts: false, usePowerFxV1CompatibilityRules: context.Features.PowerFxV1CompatibilityRules)) ||
124-
(!context.Features.PowerFxV1CompatibilityRules && DType.String.Accepts(argType, exact: true, useLegacyDateTimeAccepts: false, usePowerFxV1CompatibilityRules: context.Features.PowerFxV1CompatibilityRules))))
123+
((!context.AnalysisMode && BuiltInEnums.RemoveFlagsEnum.FormulaType._type.Accepts(argType, exact: true, useLegacyDateTimeAccepts: false, usePowerFxV1CompatibilityRules: context.Features.PowerFxV1CompatibilityRules)) ||
124+
(context.AnalysisMode && (DType.String.Accepts(argType, exact: true, useLegacyDateTimeAccepts: false, usePowerFxV1CompatibilityRules: context.Features.PowerFxV1CompatibilityRules) ||
125+
BuiltInEnums.RemoveFlagsEnum.FormulaType._type.Accepts(argType, exact: true, useLegacyDateTimeAccepts: false, usePowerFxV1CompatibilityRules: context.Features.PowerFxV1CompatibilityRules)))))
125126
{
126127
continue;
127128
}
@@ -140,30 +141,17 @@ public override bool CheckTypes(CheckTypesContext context, TexlNode[] args, DTyp
140141
(!context.Features.PowerFxV1CompatibilityRules && (!collectionAcceptsRecord && !recordAcceptsCollection)))
141142
{
142143
fValid = false;
143-
SetErrorForMismatchedColumns(collectionType, argType, args[i], errors, context.Features);
144+
if (!SetErrorForMismatchedColumns(collectionType, argType, args[i], errors, context.Features))
145+
{
146+
errors.EnsureError(DocumentErrorSeverity.Severe, args[i], TexlStrings.ErrTableDoesNotAcceptThisType);
147+
}
144148
}
145149

146150
// Only warn about no-op record inputs if there are no data sources that would use reference identity for comparison.
147151
else if (!collectionType.AssociatedDataSources.Any() && !recordAcceptsCollection)
148152
{
149153
errors.EnsureError(DocumentErrorSeverity.Warning, args[i], TexlStrings.ErrCollectionDoesNotAcceptThisType);
150154
}
151-
152-
if (!context.AnalysisMode)
153-
{
154-
// ArgType[N] (0<N<argCount) must match all the fields with the data source.
155-
bool checkAggregateNames = argType.CheckAggregateNames(collectionType, args[i], errors, context.Features, SupportsParamCoercion);
156-
157-
// The item schema should be compatible with the collection schema.
158-
if (!checkAggregateNames)
159-
{
160-
fValid = false;
161-
if (!SetErrorForMismatchedColumns(collectionType, argType, args[i], errors, context.Features))
162-
{
163-
errors.EnsureError(DocumentErrorSeverity.Severe, args[i], TexlStrings.ErrTableDoesNotAcceptThisType);
164-
}
165-
}
166-
}
167155
}
168156

169157
returnType = context.Features.PowerFxV1CompatibilityRules ? DType.Void : collectionType;
@@ -382,23 +370,8 @@ public override bool CheckTypes(CheckTypesContext context, TexlNode[] args, DTyp
382370
errors.EnsureError(args[1], TexlStrings.ErrNeedTable_Arg, args[1]);
383371
}
384372

385-
if (!context.AnalysisMode)
386-
{
387-
bool checkAggregateNames = sourceType.CheckAggregateNames(collectionType, args[1], errors, context.Features, SupportsParamCoercion);
388-
389-
// The item schema should be compatible with the collection schema.
390-
if (!checkAggregateNames)
391-
{
392-
fValid = false;
393-
if (!SetErrorForMismatchedColumns(collectionType, sourceType, args[1], errors, context.Features))
394-
{
395-
errors.EnsureError(DocumentErrorSeverity.Severe, args[1], TexlStrings.ErrTableDoesNotAcceptThisType);
396-
}
397-
}
398-
}
399-
400373
// The source schema should be compatible with the collection schema.
401-
else if (!collectionType.Accepts(sourceType, exact: true, useLegacyDateTimeAccepts: false, usePowerFxV1CompatibilityRules: context.Features.PowerFxV1CompatibilityRules) && !sourceType.Accepts(collectionType, exact: true, useLegacyDateTimeAccepts: false, usePowerFxV1CompatibilityRules: context.Features.PowerFxV1CompatibilityRules))
374+
if (!collectionType.Accepts(sourceType, exact: true, useLegacyDateTimeAccepts: false, usePowerFxV1CompatibilityRules: context.Features.PowerFxV1CompatibilityRules) && !sourceType.Accepts(collectionType, exact: true, useLegacyDateTimeAccepts: false, usePowerFxV1CompatibilityRules: context.Features.PowerFxV1CompatibilityRules))
402375
{
403376
fValid = false;
404377
if (!SetErrorForMismatchedColumns(collectionType, sourceType, args[1], errors, context.Features))

‎src/tests/Microsoft.PowerFx.Interpreter.Tests.Shared/MutationScripts/Remove.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Error({Kind:ErrorKind.Div0})
9090
Table({a:{aa:{aaa:true,bbb:true}}})
9191

9292
>> Remove(t4, {a:{aa:{aaa:true}}})
93-
Errors: Error 0-6: The function 'Remove' has some invalid arguments.|Error 11-30: Missing column. Your formula is missing a column 'a.aa.bbb' with a type of 'Boolean'.|Error 11-30: Invalid argument type. Expecting a Record value, but of a different schema.|Error 11-30: Missing column. Your formula is missing a column 'aa.bbb' with a type of 'Boolean'.
93+
Errors: Error 0-6: The function 'Remove' has some invalid arguments.|Error 11-30: Missing column. Your formula is missing a column 'a.aa.bbb' with a type of 'Boolean'.
9494

9595
>> Remove(t4, {a:{aa:{aaa:true,bbb:false}}})
9696
Error({Kind:ErrorKind.NotFound})

0 commit comments

Comments
 (0)
Please sign in to comment.