From the docs:
Write your functions in a way that, for example, calls to external functions happen after any changes to state variables in your contract so your contract is not vulnerable to a reentrancy exploit.
I was wondering if it is possible (and viable) to enforce this rule syntactically or as a check in the compiler to prevent this class of attacks?
If it is not possible, why? Is there a necessity to allow external calls anywhere in the middle of functions?
I stumbled upon EIP 214 which says:
this proposal adds a new opcode that can be used to call another contract (or itself) while disallowing any modifications to the state during the call (and its subcalls, if present).
It sounds like it addresses the problem but from the other end. My question is focused on the enforcing of non-static calls to be always placed last inside functions.