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] variants not allowed in this context is generated when the struct has the same name as the module where it is defined #14950

Closed
rahxephon89 opened this issue Oct 12, 2024 · 1 comment · Fixed by #14952
Labels
bug Something isn't working compiler-v2

Comments

@rahxephon89
Copy link
Contributor

rahxephon89 commented Oct 12, 2024

🐛 Bug

When compiling the following code using V2:

module 0x42::M {
    struct M has drop {
        v: u64
    }
}

module 0x42::M1 {
    use 0x42::M::{Self, M};

    fun test(_m: M::M): u64 {
        3
    }
}

The following error is generated:

error: variants not allowed in this context
   ┌─ tests/sources/functional/schemas_ok.move:15:18
   │
15 │     fun test(_m: M::M): u64 {
   │                  ^^^^

While V1 can compile the code.

@rahxephon89 rahxephon89 added bug Something isn't working compiler-v2 labels Oct 12, 2024
@rahxephon89 rahxephon89 changed the title [Bug][Compiler-V2] variants not allowed in this context when compiling Diem framework using V2 [Bug][Compiler-V2] variants not allowed in this context is generated when the struct has the same name as the module where it is defined Oct 13, 2024
@rahxephon89
Copy link
Contributor Author

rahxephon89 commented Oct 13, 2024

Here is a smaller example:

module 0x42::M1 {
    struct M1 has drop {
        v: u64
    }
    fun test(_m: M1::M1): u64 {
        3
    }
}

which leads to the error:

error: variants not allowed in this context
  ┌─ tests/checking/naming/module_struct_same_name.move:8:18
  │
8 │     fun test(_m: M1::M1): u64 {
  │                  ^^^^^^

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