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

Wrong type unification of enums and structs in case of name and structural equality #5598

Closed
ironcev opened this issue Feb 12, 2024 · 0 comments · Fixed by #5643
Closed

Wrong type unification of enums and structs in case of name and structural equality #5598

ironcev opened this issue Feb 12, 2024 · 0 comments · Fixed by #5643
Assignees
Labels
bug Something isn't working compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler General compiler. Should eventually become more specific as the issue is triaged

Comments

@ironcev
Copy link
Member

ironcev commented Feb 12, 2024

This example compiles, treating the two enums named E as the same type, and two struct S respectively.

// lib_a.sw
library;
pub enum E { X: u8, }
pub struct S { pub x: u8, }

...

// lib_b.sw
library;
pub enum E { X: u8, }
pub struct S { pub x: u8, }

...

// main.sw
script; 

mod lib_a;
mod lib_b;

use ::lib_a::E as Lib_A_E;
use ::lib_a::S as Lib_A_S;

use ::lib_b::E as Lib_B_E;
use ::lib_b::S as Lib_B_S;

fn main() {
  let _: Lib_A_E = Lib_B_E::X(123);     // Two different enums unified.
  let _: Lib_A_S = Lib_B_S { x: 123 };  // Two different structs unified.
}
@ironcev ironcev self-assigned this Feb 12, 2024
@ironcev ironcev added bug Something isn't working compiler General compiler. Should eventually become more specific as the issue is triaged compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen labels Feb 12, 2024
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: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler General compiler. Should eventually become more specific as the issue is triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant