-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Allow external structs. #2798
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
base: staging
Are you sure you want to change the base?
Allow external structs. #2798
Changes from 10 commits
558625f
46bf2c1
e3601da
839f17d
4112865
0085736
d7e0691
04b2a49
593ea83
2c1ca39
ad6c262
bb0b0f9
3d9c3a3
9c604cc
c854945
d4f0842
3b5fb89
832e38a
0f4bb1b
71aef7f
e5f7e3b
377e066
95364fc
ee0e0ee
c015c7d
505aecc
7e02f20
2985f4e
55038dc
1204947
4348c3f
b5826a2
96ee3a0
fd0779c
7a16a80
985a954
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need a structurally equivalent check in
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One way we could ensure that we haven't missed any equality checks is by removing all invocations of == or
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto for register types.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've got checks in There's a checkin |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -157,6 +157,17 @@ impl<N: Network> FinalizeTypes<N> { | |
| None => bail!("'{identifier}' does not exist in struct '{struct_name}'"), | ||
| } | ||
| } | ||
| // Access the member on the path to output the register type. | ||
| (FinalizeType::Plaintext(PlaintextType::ExternalStruct(locator)), Access::Member(identifier)) => { | ||
| // Retrieve the member type from the struct and check that it exists. | ||
| let external_stack = stack.get_external_stack(locator.program_id())?; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note. Suppose that first access returns a struct and then a second access goes to an external struct in that one. e.g |
||
| match external_stack.program().get_struct(locator.resource())?.members().get(identifier) { | ||
| // Retrieve the member and update `finalize_type` for the next iteration. | ||
| Some(member_type) => finalize_type = FinalizeType::Plaintext(member_type.clone()), | ||
| // Halts if the member does not exist. | ||
| None => bail!("'{identifier}' does not exist in struct '{locator}'"), | ||
| } | ||
| } | ||
| // Access the member on the path to output the register type and check that it is in bounds. | ||
| (FinalizeType::Plaintext(PlaintextType::Array(array_type)), Access::Index(index)) => { | ||
| match index < array_type.length() { | ||
|
|
@@ -193,7 +204,10 @@ impl<N: Network> FinalizeTypes<N> { | |
| None => bail!("Index out of bounds"), | ||
| } | ||
| } | ||
| (FinalizeType::Plaintext(PlaintextType::Struct(..)), Access::Index(..)) | ||
| ( | ||
| FinalizeType::Plaintext(PlaintextType::Struct(..) | PlaintextType::ExternalStruct(..)), | ||
| Access::Index(..), | ||
| ) | ||
| | (FinalizeType::Plaintext(PlaintextType::Array(..)), Access::Member(..)) | ||
| | (FinalizeType::Future(..), Access::Member(..)) => { | ||
| bail!("Invalid access `{access}`") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.