Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libraries/Microsoft.PowerFx.Core/Binding/Binder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4987,7 +4987,7 @@ private bool IsIncorrectlySideEffectful(CallNode node, out ErrorResourceKey erro
if (ancestorFunc != null &&
ancestorScopeInfo != null &&
ancestorScopeInfo.HasNondeterministicOperationOrder &&
!func.AllowedWithinNondeterministicOperationOrder)
!func.AllowedWithinNondeterministicOperationOrderWithFeatures(_features))
{
errorKey = TexlStrings.ErrFunctionDisallowedWithinNondeterministicOperationOrder;
badAncestor = ancestorScope.Call;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ internal abstract class TexlFunction : IFunction
// that have a nondeterministic operation order (due to multiple async calls).
public virtual bool AllowedWithinNondeterministicOperationOrder => true;

// Allows override for functions for which this depends on enalbed features, in particular EnhancedIterationFunctionChecks.
public virtual bool AllowedWithinNondeterministicOperationOrderWithFeatures(Features features) => AllowedWithinNondeterministicOperationOrder;

/// <summary>
/// Whether the function always produces a visible error if CheckTypes returns invalid.
/// This can be used to prevent the overall "Function has invalid arguments" error.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ internal class RecalcEngineSetFunction : TexlFunction
public override bool IsSelfContained => false;

// Set() of a simple identifier is not a mutation through a reference (a mutate), but rather changing the reference (a true set).
public override bool MutatesArg(int argIndex, TexlNode arg) => argIndex == 0 && arg.Kind != NodeKind.FirstName;
public override bool MutatesArg(int argIndex, TexlNode arg) => argIndex == 0 && arg.Kind != NodeKind.FirstName;

// If enhanced checks are enabled, overrides default true to block Set() from being used in iterator functions.
public override bool AllowedWithinNondeterministicOperationOrderWithFeatures(Features features) => !features.EnhancedIterationChecks;

public override IEnumerable<StringGetter[]> GetSignatures()
{
Expand All @@ -48,7 +51,7 @@ public RecalcEngineSetFunction()
0, // no lambdas
2,
2)
{
{
}

public override bool CheckTypes(CheckTypesContext context, TexlNode[] args, DType[] argTypes, IErrorContainer errors, out DType returnType, out Dictionary<TexlNode, DType> nodeToCoercedTypeMap)
Expand Down
Loading