Skip to content
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

A type error occurs when a Struct containing an array is used as an on-chain variable #625

Closed
Comdex opened this issue Dec 3, 2022 · 1 comment · Fixed by #758
Closed
Assignees
Labels
bug Something isn't working to-discuss Issues to be discussed further

Comments

@Comdex
Copy link
Contributor

Comdex commented Dec 3, 2022

This is a test after applying the #567 update:

class MyStruct extends Struct({ a: Field }) {}

class MyStructB extends Struct({
  a: Circuit.array(Field, 5),
}) {}

export class TestZkapp extends SmartContract {
  @state(MyStruct) myStruct = State<MyStruct>(); // work
  @state(MyStructB) myStructB = State<MyStructB>(); // type mismatch error
}
@mitschabaude
Copy link
Member

mitschabaude commented Dec 3, 2022

Thanks! The issue makes sense to me - the type error occurs when the state is not guaranteed to consist only of field elements, and Circuit.array doesn't currently return a type which distinguishes this case (in contrast to Struct itself)

@mitschabaude mitschabaude added the bug Something isn't working label Dec 7, 2022
@nicc nicc added the to-discuss Issues to be discussed further label Jan 3, 2023
@mitschabaude mitschabaude self-assigned this Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working to-discuss Issues to be discussed further
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants