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

Replacing the value of a field of a structured box can keep parts of the replaced value #74

Open
wenkanglu opened this issue Feb 6, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@wenkanglu
Copy link

wenkanglu commented Feb 6, 2023

Describe the bug
{box_name}.{field_name} = {value}. replaces the field {field_name} of box {box_name} created from a struct without considering the size of {value}. This issue tracks the bug when parts of the replaced value remain after replacing it with a byte array of a smaller size than the current value.

To Reproduce

#pragma version 8

struct UserInfo:
    favourite_colour: bytes[20]
end

if Txn.ApplicationID == 0:
    exit(1)
end

box<UserInfo> info_box = CreateBox("foo")
info_box.favourite_colour = "yellow"
info_box.favourite_colour = "red"
exit(1)

Expected behavior
Field favourite_colour of box with key "foo" should have a value of "red" but is instead "redlow".

Additional context
Related issue: #75

@wenkanglu wenkanglu added the bug Something isn't working label Feb 6, 2023
@wenkanglu wenkanglu changed the title Replacing the value of a field of a structured box can keep parts of the replaced value [BUG] Replacing the value of a field of a structured box can keep parts of the replaced value Feb 6, 2023
@fergalwalsh
Copy link
Collaborator

Discussed on Discord but want to mention here for visibility; this is being worked on as part of the current type checks work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants