Usage of a variable before its declaration (either declared later or in another scope) leads to unexpected behavior in solc < 0.5.0
but solc >= 0.5.0
implements C99-style scoping rules where variables can only be used after they have been declared and only in the same or nested scopes. (see here)
- Local Variables Pre-declaration Usage
- Declared Later
- Declared Another Scope
solc < 0.5.0
-> Undefined Behaviorsolc >= 0.5.0
-> C99-Style Scoping Rules