Bug: import mo:base/Random
Executed with moc -r bug.mo
import Random "mo:base/Random";
Stacktrace:
OOPS! You've triggered a compiler bug.
Please report this at https://github.com/dfinity/motoko/issues/new with the following details:
Motoko (source yxkbp43n-v7xxmayf-zvly3ch3-2hcb48z3)
Fatal error: exception "Assert_failure mo_interpreter/interpret.ml:466:17"
Raised at Mo_interpreter__Interpret.interpret_exp_mut.(fun) in file "mo_interpreter/interpret.ml", line 466, characters 17-29
Called from Mo_interpreter__Interpret.Scheduler.yield in file "mo_interpreter/interpret.ml", line 118, characters 8-23
Called from Mo_interpreter__Interpret.Scheduler.run in file "mo_interpreter/interpret.ml", line 121, characters 36-44
Called from Mo_interpreter__Interpret.interpret_lib in file "mo_interpreter/interpret.ml", line 981, characters 2-18
Called from Pipeline.interpret_libs in file "pipeline/pipeline.ml", line 399, characters 17-45
Called from Pipeline.interpret_files.(fun) in file "pipeline/pipeline.ml", line 417, characters 18-43
Called from Pipeline.run_files in file "pipeline/pipeline.ml", line 455, characters 20-55
Called from Moc.process_files in file "exes/moc.ml", line 137, characters 22-48
Called from Moc in file "exes/moc.ml", line 214, characters 4-23
This comes from
| V.Blob b ->
let f = match id.it with
| "size" -> blob_size
| "vals" -> blob_vals
| _ -> assert false
The attribute accessed is raw_rand :-O
let raw_rand = (actor "aaaaa-aa" : actor { raw_rand : () -> async Blob }).raw_rand;
public let blob : shared () -> async Blob = raw_rand;
The problem is that Random.mo depends on the ability to obtain entropy from the IC. As such it communicates with the management canister, and that happens via async calls. The interpreter doesn't (yet) support async calls, and is supposed to fail. @crusso please correct me if I am wrong.
That said, DotE (⟨some blob⟩, "raw_rand") should never be generated :-)
Actually, the interpreter does support async calls, but not actor references. We could probably fake up enough of actor reference "aaaaa-aa" to do raw_rand (and fail on other stuff we really can't implement, like installing wasm code).