Motoko compiler bug

Hi team,

I faced a compiler while building a test project with four canisters.
Here is the compiler callstack.

Stderr:

OOPS! You’ve triggered a compiler bug.
Please report this Motoko issue at forum.dfinity.org with the following details:

Motoko (revision dbxi6sam-c0a5q36z-svy5fggv-xbs7pwar)

Fatal error: exception “Assert_failure mo_idl/idl_to_mo.ml:106:9”
Raised at file “mo_idl/idl_to_mo.ml”, line 106, characters 9-21
Called from file “pipeline/pipeline.ml”, line 345, characters 14-61
Called from file “lang_utils/diag.ml”, line 32, characters 27-30
Called from file “lang_utils/diag.ml”, line 48, characters 20-25
Called from file “lang_utils/diag.ml”, line 32, characters 27-30
Called from file “lang_utils/diag.ml”, line 32, characters 27-30
Called from file “lang_utils/diag.ml”, line 32, characters 27-30
Called from file “lang_utils/diag.ml”, line 32, characters 27-30
Called from file “lang_utils/diag.ml”, line 32, characters 27-30
Called from file “pipeline/pipeline.ml” (inlined), line 356, characters 20-42
Called from file “pipeline/pipeline.ml”, line 358, characters 47-63
Called from file “pipeline/pipeline.ml”, line 366, characters 21-52
Called from file “lang_utils/diag.ml”, line 32, characters 27-30
Called from file “lang_utils/diag.ml”, line 32, characters 27-30
Called from file “pipeline/pipeline.ml”, line 446, characters 27-71
Called from file “exes/moc.ml”, line 136, characters 24-53
Called from file “exes/moc.ml”, line 205, characters 4-23

These should probably be filed here now that it’s open source: Issues · dfinity/motoko · GitHub

I opened a pull request to update the link in the error message.

1 Like

Hi @jasonyeoh,

It seems you are using version 0.6.1 on darwin, correct?

Note to myself, this can be confirmed with

~/dfinity/motoko $ nix eval '(builtins.toString ((import (builtins.fetchGit { url = ./.; ref = "refs/tags/0.6.1"; }) { system = "x86_64-darwin"; }).moc))'
"/nix/store/dbxi6samc0a5q36zsvy5fggvxbs7pwar-moc"

and we should automate that a bit maybe, at least.

It seems that the compiler falls over one of the candid files that you use. Maybe you use actor classes in one of the imported interfaces?

I thought we improved the error message for that… ah, no, still not fixed. This is tracked at issue Bad error message when importing did that isn't a service · Issue #2319 · dfinity/motoko · GitHub. Sorry for that!

Yea, that’s right @nomeata . I was using an importing canisters in Motoko files. Once I remove the dependencies, the compiler error disappears. This is on 0.7.0 , on darwin indeed.

Yes, SDK 0.7.0 includes Motoko 0.6.1 (yes, this can be confusing :-))

I get the same problem when I use intercanister-calls, how to fix it?
dfx 0.7.2, darwin

I suspect you are trying to import a canister that is defined as an actor class, which is unsupported for now.

You can instead import the actor class as a library, not external canister and it should work.

If that doesn’t make sense or help maybe share an outline of your code in a repo or gist so we can diagnose.

The bad error message is improved in the next release of moc.

1 Like

if I import an actor object(canister), not an actor class, it works.
Thanks.