To_candid and from_candid Errors

I am trying to use the from_candid and to_candid methods in a lib I’m working on, but I get these errors whenever I compile my code using the Motoko compiler in the vessel bin folder.

prim:50.30-50.42: execution error, to do: FromCandidE
prim:50.30-50.42: execution error, to do: ToCandidE

I tried running the code in Motoko Playground, and it works fine.
I also updated the compiler to version 0.7.3, but it still returns the same errors.

This behavior looks like it’s specific to the interpreter:

I think that’s moc -r. Is that what you’re using?

Yes, that’s what I’m using.

$(shell vessel bin)/moc -r $(shell vessel sources) -wasi-system-api ./tests/*Test.mo

I think you’d need to do something like this instead:

1 Like

Thanks! It’s working correctly now

1 Like

I seem to have triggered a compiler bug. :sweat_smile:
Please report this at Sign in to GitHub · GitHub with the following details:
Compiler Bug: Motoko 0.7.3 · Issue #3539 · dfinity/motoko · GitHub

Motoko 0.7.3 (source qwdq7q2n-npg4rjz7-7s76jv69-kbwjwklg)

Fatal error: exception Invalid_argument("Import expression found in unit body: mo:base/Blob")
Raised at Lowering__Desugar.exp' in file "lowering/desugar.ml", line 227, characters 25-111
Called from Lowering__Desugar.typed_phrase' in file "lowering/desugar.ml", line 45, characters 16-30
Called from Lowering__Desugar.dec' in file "lowering/desugar.ml", line 688, characters 13-18
Called from Lowering__Desugar.phrase' in file "lowering/desugar.ml", line 41, characters 16-34
Called from Lowering__Desugar.dec in file "lowering/desugar.ml", line 682, characters 14-30
Called from Stdlib__list.map in file "list.ml", line 92, characters 20-23
Called from Stdlib__list.map in file "list.ml", line 92, characters 32-39
Called from Stdlib__list.map in file "list.ml", line 92, characters 32-39
Called from Stdlib__list.map in file "list.ml", line 92, characters 32-39
Called from Lowering__Desugar.transform_unit_body in file "lowering/desugar.ml", line 1068, characters 26-35
Called from Lowering__Desugar.transform_unit in file "lowering/desugar.ml", line 1107, characters 14-38
Called from Pipeline.desugar_unit in file "pipeline/pipeline.ml", line 584, characters 4-22
Called from Pipeline.compile_unit in file "pipeline/pipeline.ml", line 668, characters 16-43
Called from Pipeline.compile_files in file "pipeline/pipeline.ml", line 690, characters 19-56
Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30
Called from Diag.bind in file "lang_utils/diag.ml", line 32, characters 27-30
Called from Dune__exe__Moc.process_files in file "exes/moc.ml", line 203, characters 49-94
Called from Dune__exe__Moc in file "exes/moc.ml", line 298, characters 4-23
make: *** [test1] Error 2
1 Like

Thank you @tomijaga, I pinged the Motoko folks to have a look

Thanks for the report. You didn’t include a reproduction snippet, but we need something to reliably debug and fix this problem. Normally the syntax should ensure that import clauses are only appearing at the top of the file and their content gets properly resolved. In your report something unexpected is happening.

If you could provide some materials (can be a git repo too) that would speed up troubleshooting immensely.

1 Like

I’ve added comments and links to the repo I was working on.
The issue was I was trying to compile multiple files into a single object file.
I wrote a bash script to help me with it but is there any command for compiling and running multiple files