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] Internal complier bug "struct not defined" triggered #12820

Closed
vineethk opened this issue Apr 8, 2024 · 1 comment · Fixed by #12821
Closed

[Bug][compiler-v2] Internal complier bug "struct not defined" triggered #12820

vineethk opened this issue Apr 8, 2024 · 1 comment · Fixed by #12821
Assignees
Labels
bug Something isn't working compiler-v2

Comments

@vineethk
Copy link
Contributor

vineethk commented Apr 8, 2024

🐛 Bug

When we compile the following code in v2 (taken from third_party/move/move-compiler-v2/tests/checking/inlining/resources_invalid.move):

module 0x42::objects {

    struct ReaderRef<phantom T: key> has store {
        addr: address
    }

    public inline fun reader<T: key>(ref: &ReaderRef<T>): &T {
        borrow_global<T>(ref.addr)
    }
}

module 0x42::token {
    use 0x42::objects as obj;

    struct Token has key { val: u64 }

    public fun get_value(ref: &obj::ReaderRef<Token>): u64 acquires Token {
        obj::reader(ref).val
    }
}

We get an internal compiler bug "struct not defined".

If we use the v1 compiler, we get this error instead:

- Error: error[E14002]: Inlined code invalid in this context
-   ┌─ TEMPFILE:7:26
-   │
- 7 │         borrow_global<T>(ref.addr)
-   │                          ^^^ After inlining: invalid storage operation on external type `0x42::objects::ReaderRef`
@rahxephon89
Copy link
Contributor

@vineethk, this may related to the visibility issue on structs. My PR should be able to fix it.

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.

2 participants