Void issues
-
IsError( If( false, GUID(), Now() ) )returns false -
If(false, {}, [])-> returns empty table, should be error -
If(False, {}, 1)-> returns1should be an error.
2&3 seems to be due to special casing here. https://github.com/microsoft/Power-Fx/blob/81e7c0bee1e1b3dc45f03ed302d2592cf316bd54/src/libraries/Microsoft.PowerFx.Core/Types/DType.cs#L3991 (Related PR: https://github.com/microsoft/Power-Fx/pull/1309)
A clarification. I believe IfError(Void, 1, 2) and IsError(Void) should produce a Void compile time error only when side effects are disabled.
The reason we turn a blind eye to Void results in Canvas app Button.OnSelect is so that makers can write control flow with the If function. For example, in this case where Orders {Value: Number} and BadSessions {Value: GUID} have incompatible schemas:
If( allGood,
Collect( Orders, {Value:Int(TextInput1.Text)} ),
Collect( BadSessions, {Value:SessionGUID} )
)
Makers should be able to wrap that whole formula with IfError or IsError to detect runtime problems and take appropriate actions. For example, the value of TextInput1.Text in this example may not be a parseable number.
But without side effects, the If function isn't about control flow, the formula is expected to produce a single, non Void return value. That is the breaking change that we all think is appropriate from the discussion above.
If we all agree, then the first item in Jas' list above does not require a change, after https://github.com/microsoft/Power-Fx/pull/2917 has been merged.