Stdlib: use of `include` induce errors
The following example breaks with a failwith when running:
$ cat doh.mligo
module Test = Test.Next
module C = struct
[@entry] let f () () : operation list * unit = [], ()
end
let test =
let orig = Test.originate (contract_of C) () 0tez in
let _c = Test.to_contract orig.taddr in
()
$ dune exec -- ligo run test doh.mligo
Uncaught exception:
(Not_found_s
("Map.find_exn: not found"
(Label taddr (File (doh.mligo:9:33 doh.mligo:9:38)))))
Raised at Base__Map.Tree0.find_exn.if_not_found in file "src/map.ml", line 503, characters 6-84
Called from Interpreter.eval_ligo in file "src/main/interpreter/common/interpreter.ml", line 1732, characters 14-37
Called from Interpreter__Execution_monad.eval.(fun) in file "src/main/interpreter/common/execution_monad.ml", line 897, characters 25-30
Called from Interpreter__Execution_monad.eval in file "src/main/interpreter/common/execution_monad.ml", line 896, characters 24-57
Called from Interpreter__Execution_monad.eval in file "src/main/interpreter/common/execution_monad.ml", line 896, characters 24-57
Called from Interpreter__Execution_monad.eval in file "src/main/interpreter/common/execution_monad.ml", line 896, characters 24-57
Called from Interpreter.try_eval in file "src/main/interpreter/common/interpreter.ml" (inlined), line 2229, characters 2-83
Called from Interpreter.eval_expression.(fun) in file "src/main/interpreter/common/interpreter.ml", line 2255, characters 4-73
Called from Interpreter.eval_test in file "src/main/interpreter/common/interpreter.ml", line 2295, characters 4-81
Called from Ligo_api__Run.test.(fun) in file "src/main/api/common/run.ml", line 33, characters 23-73
Called from Simple_utils__Trace.to_stdlib_result_lwt.(fun) in file "vendored-dune/ligo-utils/simple-utils/trace.ml", line 127, characters 20-28
Called from Lwt.Sequential_composition.backtrace_catch in file "src/core/lwt.ml", line 2077, characters 10-14
Re-raised at Simple_utils__Trace.try_with_lwt.(fun) in file "vendored-dune/ligo-utils/simple-utils/trace.ml", line 73, characters 2-60
Re-raised at Lwt.Miscellaneous.poll in file "src/core/lwt.ml", line 3123, characters 20-29
Called from Lwt_main.run.run_loop in file "src/unix/lwt_main.ml", line 27, characters 10-20
Called from Lwt_main.run in file "src/unix/lwt_main.ml", line 106, characters 8-13
Re-raised at Lwt_main.run in file "src/unix/lwt_main.ml", line 112, characters 4-13
Called from Cli_helpers.return_result_lwt.get_formatted_result in file "src/main/helpers/cli_helpers.ml", line 202, characters 19-84
Re-raised at Cli.run in file "src/bin/cli.ml", line 3595, characters 4-13
Called from Dune__exe__Runligo in file "src/bin/runligo.ml", line 2, characters 15-25
A similar bug was reported at #ligo (related to monomorphisation).
AFAIU, the reason behind these bugs is actually the usage of include
in the stdlib (likely aggregation?), as this fixes it:
diff --git a/src/main/build/ligo_lib/std_lib.mligo b/src/main/build/ligo_lib/std_lib.mligo
index 0f93ef0fd8..8165a40e2f 100644
--- a/src/main/build/ligo_lib/std_lib.mligo
+++ b/src/main/build/ligo_lib/std_lib.mligo
@@ -3618,6 +3618,7 @@ module Test = struct
end
let originate = Originate.contract
let failwith = Assert.failwith
- include Typed_address
+ let to_contract = Typed_address.to_contract
+ (* include Typed_address *)
end
end