onflow / cadence

Cadence, the resource-oriented smart contract programming language 🏃‍♂️
https://developers.flow.com/cadence
Apache License 2.0
526 stars 136 forks source link

FunctionExpressionInConditionError seems to be unnecessary after Purity check in conditions. #3434

Open bluesign opened 1 week ago

bluesign commented 1 week ago

Issue to be solved

It may be good idea to remove it, this will allow conditional event emitting etc.

Suggested Solution

I think removing should be safe, but history on git doesn't go that far.

turbolent commented 1 week ago

Function expressions in conditions got forbidden because the implementation of the post-condition rewriting does not (yet) support them (see BeforeExtractor.ExtractFunction). Post conditions are rewritten to support the before special expression. We could probably allow function expressions in pre-conditions, but still need to double check that does not lead to security issues.