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

Reference invalidation doesn't track inner resource moves #2458

Closed
SupunS opened this issue Apr 20, 2023 · 3 comments
Closed

Reference invalidation doesn't track inner resource moves #2458

SupunS opened this issue Apr 20, 2023 · 3 comments
Assignees
Labels
Bug Something isn't working

Comments

@SupunS
Copy link
Member

SupunS commented Apr 20, 2023

Current Behavior

Imagine a nested resource like:

resource Foo {
    let bar: @Bar
}

resource Bar {
    let id: UInt8
}

Then get a reference to the inner field, and move the outer resource:

// Get a reference to the inner resource
var barRef = &foo.bar as &Bar

// Move the resource
var foo2 <- foo

// Access the moved resource through the reference
barRef.id    // <-- This should panic, but currently doesn't

Expected Behavior

See above

Steps To Reproduce

See above

Environment

- Cadence version: Stable Cadence (not applicable for the master branch or any released versions)
@SupunS SupunS added the Bug Something isn't working label Apr 20, 2023
@SupunS SupunS self-assigned this Apr 20, 2023
@bluesign
Copy link
Contributor

not applicable for the master branch or any released versions

is this only happening in Stable Cadence version? Or it means we only have reference tracking changes in Stables Cadence.

@SupunS
Copy link
Member Author

SupunS commented Apr 25, 2023

The reference tracking is there in both branches, but the purpose of the tracking and how it is implemented is different in the two branches. e.g: in master branch, the tracking is used to keep the reference valid, whereas, in stable-cadence, tracking is used to invalidate the reference. This change was done in #1999.

This reported problem only exists in the stable cadence branch. More like a bug in #1999.

@SupunS
Copy link
Member Author

SupunS commented Aug 9, 2023

Fixed in #2460

@SupunS SupunS closed this as completed Aug 9, 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
Projects
None yet
Development

No branches or pull requests

2 participants