Open ghallak opened 7 months ago
@hanssv Do you think that the following contract should compile? Should init
only be required only when clone
is called on the contract interface or should it be required for all contract interfaces where state is not unit
?
contract interface I =
record state = { x : int }
entrypoint f : () => state
main contract C =
entrypoint g(c : I) : int = c.f().x
@hanssv Do you think that the following contract should compile? Should
init
only be required only whenclone
is called on the contract interface or should it be required for all contract interfaces where state is notunit
?contract interface I = record state = { x : int } entrypoint f : () => state main contract C = entrypoint g(c : I) : int = c.f().x
In general the interfaces only need to contain what is used in the main contract, so in that spirit I think it should compile, yes. But it wouldn't be the end of the world if it doesn't. But let's see if we can collect a few more opinions.
Right now we have a special void
type for cases where we don't really care what a thing is, but we want to make it unusable (like in the case of init
in interfaces). I think we should stick to that and even more - enforce interface init to return void, since we have no way to check what is the type of the contract's actual state.
But for clone
the type is needed, right? But since that is the only case where init
is "useable" that could be the only place we require to list init
?!
For clone
you only need arguments. The return type should remain opaque, however. I am thinking of making it either some explicitly "unknown" type such as void
or ???
, or some hardcoded (and equally unusable) NameOfTheInterface.state
This PR fixes the issue that prevents the compilation of contract interfaces in which state type is defined. Example: