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

[Bug][Compiler-v2] index notation does not check ability properly #15274

Closed
rahxephon89 opened this issue Nov 14, 2024 · 0 comments · Fixed by #15281
Closed

[Bug][Compiler-v2] index notation does not check ability properly #15274

rahxephon89 opened this issue Nov 14, 2024 · 0 comments · Fixed by #15281
Assignees
Labels
bug Something isn't working compiler-v2

Comments

@rahxephon89
Copy link
Contributor

🐛 Bug

When compiling the following code,

    struct Wrapper<T: copy> has drop, key, store, copy {
        inner: T
    }

    fun unwrap<T: copy>(self: &Wrapper<T>): T {
        self.inner
    }

    fun dispatch<T: copy>(account: address): T acquires Wrapper {
        unwrap(&Wrapper<T>[account])
    }

The following bytecode verification error is generated:

 bug: bytecode verification failed with unexpected status code `CONSTRAINT_NOT_SATISFIED`. This is a compiler bug, consider reporting it.
Error message: missing abilities for `ImmBorrowGlobalGeneric(StructDefInstantiationIndex(0))` at code offset 1

If we change unwrap(&Wrapper<T>[account]) into unwrap(borrow_global<Wrapper<T>>), the following error is generated:

 error: type `T` is missing required ability `store`
    ┌─ TEMPFILE:298:23
    │
298 │         borrow_global<Wrapper<T>>(account).unwrap()
    │                       ^^^^^^^^^^
    │
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler-v2
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant