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 resolution of items imported via alias and shadowed with local items #5599

Open
ironcev opened this issue Feb 12, 2024 · 0 comments
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, and shows that aliases LibE and LibS get resolved to the local items instead to the items imported from the library.

// lib.sw
library;

pub enum E { X: u8, }         // No `Y` variant.
pub struct S { pub x: u8, }   // No `y` field.

...

// main.sw
script;

mod lib;

use ::lib::E as LibE;
use ::lib::S as LibS;

enum E {
  X: u8,
  Y: u8,   // <--- Additional variant.
}

struct S {
  x: u8,
  y: u8,   // <--- Additional field.
}

fn main() {
  let _: LibE = E::Y(123);
  let _: LibS = S { x: 123, y: 123 };

  let _: LibE = LibE::Y(123);
  let _: LibS = LibS { x: 123, y: 123 };
}

Related to #5500.

@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

No branches or pull requests

2 participants