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

error: failed when building. moonc version: v0.1.20241218+f4a066f5f #371

Open
FlyCloudC opened this issue Dec 19, 2024 · 1 comment
Open
Assignees
Labels
bug Something isn't working

Comments

@FlyCloudC
Copy link

create project:

moon new --lib project1
cd ./project1

edit ./sec/top.mbt :

///|
pub(open) trait Abelian {
  proof() -> Unit
}

///|
pub impl[A : Abelian] Abelian for A? with proof() {  }

run build command:

moon build

output:

failed: moonc build-package -error-format json D:\Code\moonbit\bug\project1\src\top.mbt -o D:\Code\moonbit\bug\project1\target\wasm-gc\release\build\hello.core -pkg username/hello -std-path C:\Users\FlyCloudC\.moon\lib\core\target\wasm-gc\release\bundle -i D:\Code\moonbit\bug\project1\target\wasm-gc\release\build\lib\lib.mi:lib -pkg-sources username/hello:D:\Code\moonbit\bug\project1\src -target wasm-gc

         --  --
       /  //  / __--------_
      /  //  /_/            \
   ---      -                \ __
  / X        /        ____   /   )
  *_________/__/_____/______/ `--

Oops, the compiler has encountered an unexpected situation.
This is a bug in the compiler.

A bug report containing the error description and relevant code would be
greatly appreciated. You can submit the bug report here:

  https://github.com/moonbitlang/moonbit-docs/issues/new?labels=bug,ICE

Error: Moonc.Hashed_type.Unresolved_type_variable

Compiler args: moonc build-package -error-format json "D:\\Code\\moonbit\\bug\\project1\\src\\top.mbt" -o "D:\\Code\\moonbit\\bug\\project1\\target\\wasm-gc\\release\\build\\hello.core" -pkg username/hello -std-path "C:\\Users\\FlyCloudC\\.moon\\lib\\core\\target\\wasm-gc\\release\\bundle" -i "D:\\Code\\moonbit\\bug\\project1\\target\\wasm-gc\\release\\build\\lib\\lib.mi:lib" -pkg-sources "username/hello:D:\\Code\\moonbit\\bug\\project1\\src" -target wasm-gc

moonc version: v0.1.20241218+f4a066f5f
error: failed when building
@peter-jerry-ye peter-jerry-ye added the bug Something isn't working label Dec 19, 2024
@codeworm96
Copy link

I found it is also reproducible in the open-sourced v0.1.20241202 version.

https://github.com/moonbitlang/moonbit-compiler/blob/main/src/poly_type.ml#L92 Here a fresh type variable is made for the type parameter A.

Because the type variable is unused, the unification of the method does not bound the type variable: https://github.com/moonbitlang/moonbit-compiler/blob/main/src/toplevel_typer.ml#L2031

Later when we solve the constraints, the unresolved type variable will raise the error because it cannot be hashed.

I think it is a case where the compiler should catch and print the compilation failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants