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

Build succeeds silently when exporting methods with duplicate names #589

Open
1 task done
FlyCloudC opened this issue Feb 7, 2025 · 2 comments
Open
1 task done
Assignees

Comments

@FlyCloudC
Copy link

Bug Report

Environment

OS

Operating System: Windows

MoonBit CLI Tools Version

moon 0.1.20250121 (a825806 2025-01-21) ~\.moon\bin\moon.exe
moonc v0.1.20250121+7fc3467ab ~\.moon\bin\moonc.exe
moonrun 0.1.20250121 (a825806 2025-01-21) ~\.moon\bin\moonrun.exe

Steps to Reproduce

top.mbt :

///|
pub type A Int

///|
pub type B Int

///|
pub fn A::from_int(x : Int) -> A {
  A(x)
}

///|
pub fn B::from_int(x : Int) -> B {
  B(x)
}

mod.pkg.json:

{
    "link": {
        "js": {
            "exports": [
                "from_int"
            ]
        }
    }
}

run moon build --target=js

Expected Behavior

Throw an error to remind that there is a duplicate name.

Actual Behavior

Build succeeds. target/js/release/project1.js:

function username$project1$$A$from_int(x) {
  return x;
}
function username$project1$$B$from_int(x) {
  return x;
}
export { username$project1$$A$from_int as from_int, username$project1$$B$from_int as from_int }

Checklist

  • (Optional) My case is minimal enough to be reproducible.
@FlyCloudC
Copy link
Author

FlyCloudC commented Feb 7, 2025

In addition, I'd like to ask if a feature to "export only A::from_int" will be provided.

@Young-Flash
Copy link
Collaborator

cc @Guest0x0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants