You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR fixes the issue that prevents the compilation of contract interfaces in which state type is defined. Example:
contract interface I =
record state = { x : int }
entrypoint f : () => state
entrypoint init : () => 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 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 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
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes the issue that prevents the compilation of contract interfaces in which state type is defined. Example: