dfinity / motoko

Simple high-level language for writing Internet Computer canisters

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inter-canister call in optionally defined async function triggers compiler bug

AndyGura opened this issue · comments

commented

I managed to trigger a compiler bug by doing inter-canister call inside of "optionally" defined async function.

Minimal actor code which reproduces the bug

import Principal "mo:base/Principal";

actor class Main(principal : ?Principal) = self {

  switch (principal) {
    case (null) {};
    case (?p) {
      func f() : async () {
        let canister = actor (Principal.toText(p)) : actor {
          a : () -> async ();
        };
        await canister.a();
      };
    };
  };
};

Compiler version
0.11.1

Console output

OOPS! You've triggered a compiler bug.
Please report this at https://github.com/dfinity/motoko/issues/new with the following details:

Motoko 0.11.1 (source xqq6zkb5-mhafjk7m-n1samsmj-l4gq1143)

Fatal error: exception Codegen.Compile.CodegenError("internal error: const \"f\": captures \"$$p/0/0\", not found in static environment\n")
Raised at Codegen__Compile.fatal.(fun) in file "codegen/compile.ml", line 174, characters 42-64
Called from Stdlib__list.iter in file "list.ml", line 110, characters 12-15
Called from Codegen__Compile.compile_const_exp.mk_body in file "codegen/compile.ml", line 12442, characters 6-230
Called from Codegen__Compile.FuncDec.compile_local_function.(fun) in file "codegen/compile.ml", line 9148, characters 20-37
Called from Codegen__Compile.Func.of_body in file "codegen/compile.ml", line 994, characters 6-18
Called from CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 31, characters 17-27
Re-raised at CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 36, characters 4-11
Called from Lib.AllocOnUse.use in file "lib/lib.ml", line 598, characters 13-28
Called from Codegen__Compile.StackRep.materialize_const_v in file "codegen/compile.ml", line 8742, characters 58-69
Called from Lib.Promise.lazy_value in file "lib/lib.ml", line 540, characters 14-18
Called from Codegen__Compile.StackRep.adjust in file "codegen/compile.ml", line 8800, characters 48-75
Called from Codegen__Compile.compile_exp_with_hint.(fun) in file "codegen/compile.ml", line 11999, characters 28-59
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 Codegen__Compile.compile_exp_with_hint.(fun) in file "codegen/compile.ml", line 11998, characters 29-146
Called from Codegen__InstrList.with_current_depth in file "codegen/instrList.ml", line 199, characters 23-32
Called from Codegen__Compile.FakeMultiVal.block_ in file "codegen/compile.ml", line 976, characters 25-115
Called from Codegen__Compile.compile_exp_with_hint in file "codegen/compile.ml", line 11997, characters 4-314
Called from Codegen__Compile.compile_exp_as_opt in file "codegen/compile.ml", line 12069, characters 20-59
Called from Codegen__Compile.compile_dec.(fun) in file "codegen/compile.ml", line 12362, characters 29-59
Called from Codegen__Compile.compile_dec.(fun) in file "codegen/compile.ml", line 12337, characters 29-41
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.go.(fun) in file "codegen/compile.ml", line 12404, characters 44-62
Called from Codegen__Compile.compile_decs_public.(fun) in file "codegen/compile.ml", line 12407, characters 39-61
Called from Codegen__Compile.main_actor.(fun) in file "codegen/compile.ml", line 12698, characters 4-21
Called from Codegen__Compile.Func.of_body in file "codegen/compile.ml", line 994, characters 6-18
Called from CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 31, characters 17-27
Re-raised at CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 36, characters 4-11
Called from Lib.AllocOnUse.use in file "lib/lib.ml", line 598, characters 13-28
Called from Codegen__Compile.E.built_in in file "codegen/compile.ml" (inlined), line 611, characters 4-49
Called from Codegen__Compile.IC.export_init.(fun) in file "codegen/compile.ml", line 5166, characters 20-43
Called from Codegen__Compile.Func.of_body in file "codegen/compile.ml", line 994, characters 6-18
Called from Codegen__Compile.IC.export_init in file "codegen/compile.ml", line 5164, characters 18-227
Called from Codegen__Compile.compile in file "codegen/compile.ml", line 12824, characters 6-24
Called from Pipeline.compile_files in file "pipeline/pipeline.ml", line 728, 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 244, characters 49-94
Called from Dune__exe__Moc in file "exes/moc.ml", line 341, characters 4-23