Issue https://github.com/microsoft/Power-Fx/issues/2461.
This commit is contained in:
Anderson Silva 2024-06-19 16:24:54 -05:00 коммит произвёл GitHub
Родитель ddede555b3
Коммит 75fa623c95
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 11 добавлений и 45 удалений

Просмотреть файл

@ -65,8 +65,6 @@ namespace Microsoft.PowerFx
internal bool PowerFxV1CompatibilityRules { get; set; }
internal bool SkipExpandableSetSemantics { get; set; }
/// <summary>
/// This is required by AsType() in PA delegation analysis.
/// </summary>
@ -93,23 +91,6 @@ namespace Microsoft.PowerFx
/// </summary>
internal bool IsLookUpReductionDelegationEnabled { get; set; }
/// <summary>
/// This is specific for Cards team and it is a temporary feature.
/// It will be soon deleted.
/// </summary>
[Obsolete]
internal static Features PowerFxV1AllowSetExpandedTypes
{
get
{
var ret = PowerFxV1;
ret.SkipExpandableSetSemantics = true;
return ret;
}
}
internal static Features None => new Features();
public static Features PowerFxV1 => new Features

Просмотреть файл

@ -86,24 +86,16 @@ namespace Microsoft.PowerFx.Interpreter
if (arg1.AggregateHasExpandedType())
{
if (binding.Features.SkipExpandableSetSemantics)
if (arg1.IsTable)
{
errors.EnsureError(DocumentErrorSeverity.Warning, args[1], WrnSetExpandableType);
errors.EnsureError(DocumentErrorSeverity.Critical, args[1], ErrSetVariableWithRelationshipNotAllowTable);
return;
}
else
{
if (arg1.IsTable)
{
errors.EnsureError(DocumentErrorSeverity.Critical, args[1], ErrSetVariableWithRelationshipNotAllowTable);
return;
}
if (arg1.IsRecord)
{
errors.EnsureError(DocumentErrorSeverity.Critical, args[1], ErrSetVariableWithRelationshipNotAllowRecord);
return;
}
if (arg1.IsRecord)
{
errors.EnsureError(DocumentErrorSeverity.Critical, args[1], ErrSetVariableWithRelationshipNotAllowRecord);
return;
}
}

Просмотреть файл

@ -102,9 +102,10 @@ namespace Microsoft.PowerFx.Interpreter.Tests
Assert.Equal(anonymized, check.ApplyGetLogging());
}
// This was previously allowed to unblock Cards team. This is not longer allowed.
[Theory]
[InlineData("Set(x, Table)")]
public async Task SkipExpandableSetSemanticsFeatureTest(string expr)
public async Task RemovingSkipExpandableSetSemanticsFeatureTest(string expr)
{
var databaseTable = DatabaseTable.CreateTestTable(patchDelay: 0);
var symbols = new SymbolTable();
@ -113,23 +114,15 @@ namespace Microsoft.PowerFx.Interpreter.Tests
symbols.EnableMutationFunctions();
// Temporary feature to unblock Cards team
#pragma warning disable CS0612 // Type or member is obsolete
var config = new PowerFxConfig(Features.PowerFxV1AllowSetExpandedTypes);
#pragma warning restore CS0612 // Type or member is obsolete
var engine = new RecalcEngine(config);
//var config = new PowerFxConfig(Features.PowerFxV1AllowSetExpandedTypes);
var engine = new RecalcEngine(new PowerFxConfig());
var runtimeConfig = new SymbolValues(symbols);
engine.UpdateVariable("x", TableValue.NewTable(RecordType.Empty()));
runtimeConfig.Set(slot, databaseTable);
var check = engine.Check(expr, symbolTable: symbols, options: new ParserOptions() { AllowsSideEffects = true });
// This will be success due to SkipExpandableSetSemantics feature that loosens some Set semantics conditions.
Assert.True(check.IsSuccess);
Assert.Contains(check.Errors, err => err.IsWarning && err.MessageKey == "WrnSetExpandableType");
var result = await check.GetEvaluator().EvalAsync(CancellationToken.None, symbolValues: symbols.CreateValues());
Assert.IsType<VoidValue>(result);
Assert.False(check.IsSuccess);
}
[Theory]