solidity-ide
solidity-ide copied to clipboard
Implement new BuiltInDeclarations for 0.5.0
Derived from: #132 Depending on: #148, #229
For 0.5.0 support we need new BuildInDeclarations that respect the changes to build in function signatures. In order to maintain backward compatibility, we need to refactor BuildInDeclarations and introduce solidity-version specific instances.
TODO:
- Create a 0.5.0 specific BuildInDeclarations
- add new BuildInDeclarations to Provider created in #148
From Solidity changelog
Change every .call() to a .call("") and every .call(signature, a, b, c) to use .call(abi.encodeWithSignature(signature, a, b, c)) (the last one only works for value types).
Call is currently an Operation of address. It is defined in com.yakindu.solidity.typesystem.SolidityTypeSystem. So besides the new BuiltInDeclarations for 0.5.0 we also need a second SolidityTypeSystem... (#157)
0.5.0 Preparation checklist. All checkt items are either implemented or irrelevant: Language changes:
- [x] General: Disallow var keyword.
- [x] General: Disallow the throw statement. This was already the case in the experimental 0.5.0 mode.
- [x] General: Disallow the years unit denomination (was already deprecated in 0.4.24)
- [x] General: Introduce emit as a keyword instead of parsing it as identifier.
- [x] General: New keywords: calldata
- [x] General: New keywords: constructor
- [x] General: New reserved keywords: alias, apply, auto, copyof, define, immutable, implements, macro, mutable, override, partial, promise, reference, sealed, sizeof, supports, typedef and unchecked.
- [x] Parser: Disallow uppercase X in hex number literals
- [x] Explicitly state the data location for all variables of struct, array or mapping types (including function parameters), e.g. change uint[] x = m_x to uint[] storage x = m_x. Note that external functions require parameters with a data location of calldata.
- [x] Declare variables and especially function arguments as address payable, if you want to call transfer on them.
- [x] General: Allow appending calldata keyword to types, to explicitly specify data location for arguments of external functions.
Scope Provider:
- [ ] General: C99-style scoping rules are enforced now. This was already the case in the experimental 0.5.0 mode.
- [x] Explicitly convert values of contract type to addresses before using an address member. Example: if c is a contract, change c.transfer(...) to address(c).transfer(...)
BuiltInFunctions / TypeSystem:
- [x] General: Disallow sha3 and suicide aliases.
- [x] ABI Encoder: Properly pad data from calldata (msg.data and external function parameters). Use abi.encodePacked for unpadded encoding.
- [ ] General: Add staticcall to address. (relates to #230)
- [ ] General: Support pop() for storage arrays. ( #236)
- [x] Type Checker: Only accept a single bytes type for .call() (and family), keccak256(), sha256() and ripemd160()
Possible new Quickfixes:
- [ ] Type Checker: Disallow assignments between tuples with different numbers of components. This was already the case in the experimental 0.5.0 mode. (#230)
- [x] Type Checker: Disallow values for constants that are not compile-time constants. This was already the case in the experimental 0.5.0 mode.
- [x] Type Checker: Disallow arithmetic operations for boolean variables.
- [x] Type Checker: Disallow tight packing of literals. This was already the case in the experimental 0.5.0 mode.
- [x] Type Checker: Disallow calling base constructors without parentheses. This was already the case in the experimental 0.5.0 mode.
- [x] Type Checker: Disallow conversions between bytesX and uintY of different size.
- [x] Type Checker: Disallow conversions between unrelated contract types. Explicit conversion via address can still achieve it.
- [x] Type Checker: Disallow empty return statements for functions with one or more return values.
- [ ] Type Checker: Disallow empty tuple components. This was partly already the case in the experimental 0.5.0 mode. (#230)
- [x] Type Checker: Disallow multi-variable declarations with mismatching number of values. This was already the case in the experimental 0.5.0 mode.
- [x] Type Checker: Disallow specifying base constructor arguments multiple times in the same inheritance hierarchy. This was already the case in the experimental 0.5.0 mode.
- [x] Type Checker: Disallow calling constructor with wrong argument count. This was already the case in the experimental 0.5.0 mode.
- [x] Type Checker: Disallow uninitialized storage variables. This was already the case in the experimental 0.5.0 mode.
- [x] Type Checker: Detecting cyclic dependencies in variables and structs is limited in recursion to 256.
- [x] Type Checker: Require explicit data location for all variables, including function parameters. This was partly already the case in the experimental 0.5.0 mode.
- [x] Type Checker: Fallback function must be external. This was already the case in the experimental 0.5.0 mode.
- [x] Type Checker: Interface functions must be declared external. This was already the case in the experimental 0.5.0 mode.
- [x] Type Checker: Address members are not included in contract types anymore. An explicit conversion is now required before invoking an address member from a contract.
- [ ] Type Checker: Disallow "loose assembly" syntax entirely. This means that jump labels, jumps and non-functional instructions cannot be used anymore.
- [x] Type System: Disallow explicit and implicit conversions from decimal literals to bytesXX types.
- [x] Type System: Disallow explicit and implicit conversions from hex literals to bytesXX types of different size.
- [x] Type System: Distinguish between payable and non-payable address types.
- [x] View Pure Checker: Disallow msg.value in (or introducing it via a modifier to) a non-payable function.
- [x] Syntax Checker: Disallow functions without implementation to use modifiers. This was already the case in the experimental 0.5.0 mode.
- [ ] Syntax Checker: Named return values in function types are an error.
- [x] Syntax Checker: Strictly require visibility specifier for functions. This was already the case in the experimental 0.5.0 mode.
- [ ] Syntax Checker: Disallow unary +. This was already the case in the experimental 0.5.0 mode.
- [ ] Syntax Checker: Disallow single statement variable declaration inside if/while/for bodies that are not blocks.
- [x] View Pure Checker: Strictly enforce state mutability. This was already the case in the experimental 0.5.0 mode.
- [x] General: Disallow zero length for fixed-size arrays.
- [x] General: Disallow combining hex numbers with unit denominations (e.g. 0x1e wei). This was already the case in the experimental 0.5.0 mode.
Check for relevance:
- [x] Parser: Remove constant as function state mutability modifier.