Zilliqa / scilla-rtl

Execute Scilla code compiled by the Scilla -> LLVM compiler.
GNU General Public License v3.0
8 stars 3 forks source link

Parse unknown assignable types #26

Closed vaivaswatha closed 3 years ago

vaivaswatha commented 3 years ago

In #25 , there are tests introduced in which the type specified in the state of a remote contract aren't defined in the contract being tested. However, these types are assignable to the ones in the contract being tested.

For example, the test init_assignable_map_types defines a remote field admin with type T1 : ByStr20 with contract field x : 0x1234567890123456789012345678901234567890.LocalType end. This type fails to be parsed because LocalType isn't known to the VM (as there can be no type descriptor generated for it by the compiler). The requirement for admin is only T : ByStr20 with end as defined in remote_state_reads.scilla. i.e., T1 is assignable to T, and hence this must be parsable and accepted.

Another example. In test _4, state_4.json specifies owners to have type Map (ByStr20 with contract field paused : Bool end) Bool. This type is nowhere defined in the contract and hence no type descriptor exists. It is however assignable to Map (ByStr20 with end) Bool which is what is expected for the remote field owners in the contract.

I suppose the solution is for the type parser to accept an additional parameter "expected type" and skip parsing at points where assignability is already satisfied, so that parsing unknown types won't be an error.

Also see https://github.com/Zilliqa/scilla-compiler/issues/68