-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce the ContractCaller<AbiName>
type
#1187
Merged
Merged
Conversation
This file contains 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
adlerjohn
added
compiler
General compiler. Should eventually become more specific as the issue is triaged
language feature
Core language features visible to end users
labels
Apr 7, 2022
adlerjohn
reviewed
Apr 7, 2022
test/src/e2e_vm_tests/test_programs/should_pass/language/contract_caller_as_type/Forc.toml
Outdated
Show resolved
Hide resolved
sezna
requested review from
emilyaherbert,
canndrew,
otrho,
adlerjohn,
mohammadfawaz and
nfurfaro
April 8, 2022 00:20
nfurfaro
previously approved these changes
Apr 8, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, mostly focused on how a sway dev would use this and I like it.
sway-core/src/semantic_analysis/ast_node/expression/typed_expression_variant.rs
Outdated
Show resolved
Hide resolved
test/src/e2e_vm_tests/test_programs/should_pass/language/contract_caller_as_type/.gitignore
Show resolved
Hide resolved
adlerjohn
reviewed
Apr 8, 2022
test/src/e2e_vm_tests/test_programs/should_fail/different_contract_caller_types/Forc.toml
Outdated
Show resolved
Hide resolved
test/src/e2e_vm_tests/test_programs/should_fail/different_contract_caller_types/Forc.toml
Show resolved
Hide resolved
test/src/e2e_vm_tests/test_programs/should_pass/language/contract_caller_as_type/Forc.toml
Show resolved
Hide resolved
… into sezna/contract-caller-type
adlerjohn
reviewed
Apr 8, 2022
test/src/e2e_vm_tests/test_programs/should_fail/different_contract_caller_types/Forc.lock
Show resolved
Hide resolved
sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs
Outdated
Show resolved
Hide resolved
otrho
previously approved these changes
Apr 8, 2022
otrho
approved these changes
Apr 8, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
compiler
General compiler. Should eventually become more specific as the issue is triaged
language feature
Core language features visible to end users
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 unblocks adding a layer of abstraction around
abi
casting and usingContractId
s for that. Closes #947, and I think that's the only issue for this?ContractCaller<_>
type to have a dynamic ABI return (since it's all in the type system anyway)Associated fixes:
OwnedCallPath
Extra notes
ABI types are kind of weird. ABI casts and contract caller types are entirely known at compile time and zero-sized at runtime. So, the type system kind of "solves" these expressions (i.e. constantly evaluates them). This is because we need to know all of the details of the ABI at codegen time in order to properly format the
CALL
opcode and the data it needs.This PR makes three main concessions for handling ABIs as expressions: parsing of contract caller types, the
AbiName
expression and some type-engine logic aroundContractCaller
s. The type engine logic is a best attempt at what seems "sensible" for the type system to do, given the special-caseness of these types.