You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let { wrap } = import! std.applicative
let { flat_map } = import! std.monad
type Id a = a
let id_functor: Functor Id = {
map = \f x -> f x,
}
let id_applicative: Applicative Id = {
functor = id_functor,
apply = \f x -> f x,
wrap = \x -> x,
}
let id_monad: Monad Id = {
applicative = id_applicative,
flat_map = \f x -> f x,
}
let foo: [Functor f] -> Id () = ()
let bar: Id () =
do _ = foo
wrap ()
gluon panics with "Unexpected type [std.functor.Functor example.Id] -> example.Id () is not a function". The panic goes away if I use flat_map instead of do-notation, or if I remove the implicit parameter on foo, so I assume it arises from some interaction between the two features.
I'm using gluon-repl compiled from source from release 0.8.1.
Full stacktrace:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "Unexpected type [std.functor.Functor ice.Id] -> ice.Id () is not a function"', libcore/result.rs:945:5
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
1: std::sys_common::backtrace::print
2: std::panicking::default_hook::{{closure}}
3: std::panicking::default_hook
4: std::panicking::rust_panic_with_hook
5: std::panicking::begin_panic_fmt
6: rust_begin_unwind
7: core::panicking::panic_fmt
8: core::result::unwrap_failed
at /checkout/src/libcore/macros.rs:26
9: <core::result::Result<T, E>>::unwrap
at /checkout/src/libcore/result.rs:782
10: gluon_base::ast::Typed::env_type_of
at ./base/src/ast.rs:832
11: gluon_vm::core::Translator::translate_
at vm/src/core/mod.rs:536
12: gluon_vm::core::Translator::translate
at vm/src/core/mod.rs:296
13: gluon_vm::core::Translator::translate_alloc
at vm/src/core/mod.rs:286
14: gluon_vm::core::Translator::translate_let::{{closure}}
at vm/src/core/mod.rs:639
15: <core::slice::Iter<'a, T> as core::iter::traits::DoubleEndedIterator>::rfold
at /checkout/src/libcore/slice/mod.rs:2798
16: <core::iter::Rev<I> as core::iter::iterator::Iterator>::fold
at /checkout/src/libcore/iter/mod.rs:454
17: gluon_vm::core::Translator::translate_let
at vm/src/core/mod.rs:623
18: gluon_vm::core::Translator::translate::{{closure}}
at vm/src/core/mod.rs:300
19: <core::slice::Iter<'a, T> as core::iter::traits::DoubleEndedIterator>::rfold
at /checkout/src/libcore/slice/mod.rs:2798
20: <core::iter::Rev<I> as core::iter::iterator::Iterator>::fold
at /checkout/src/libcore/iter/mod.rs:454
21: gluon_vm::core::Translator::translate
at vm/src/core/mod.rs:297
22: gluon_vm::core::Translator::translate_
at vm/src/core/mod.rs:523
23: gluon_vm::core::Translator::translate
at vm/src/core/mod.rs:296
24: <gluon::compiler_pipeline::TypecheckValue<E> as gluon::compiler_pipeline::Compileable<Extra>>::compile
at src/compiler_pipeline.rs:592
25: <C as gluon::compiler_pipeline::Executable<'vm, Extra>>::load_script
at src/compiler_pipeline.rs:698
26: <gluon::import::DefaultImporter as gluon::import::Importer>::import::{{closure}}
at src/import.rs:151
27: <core::result::Result<T, E>>::and_then
at /checkout/src/libcore/result.rs:621
28: <gluon::import::DefaultImporter as gluon::import::Importer>::import
at src/import.rs:150
29: <gluon::import::Import<I>>::load_module_
at src/import.rs:392
30: <gluon::import::Import<I>>::load_module
at src/import.rs:319
31: gluon::Compiler::load_file_async
at src/lib.rs:485
32: gluon::Compiler::load_file
at src/lib.rs:458
33: gluon::run_files
at repl/src/main.rs:149
34: gluon::run
at repl/src/main.rs:259
35: gluon::main
at repl/src/main.rs:276
36: std::rt::lang_start::{{closure}}
at /checkout/src/libstd/rt.rs:74
37: std::panicking::try::do_call
38: __rust_maybe_catch_panic
39: std::rt::lang_start_internal
40: std::rt::lang_start
at /checkout/src/libstd/rt.rs:74
41: main
42: __libc_start_main
43: _start
at ../sysdeps/x86_64/start.S:120
The text was updated successfully, but these errors were encountered:
The problem also accurs on master.
It appears the comes from the fact that the get_return_type function gets called with the type [Functor Id] -> Id () and arg_count=1. Then it tries to match this to a function type after passing it through remove_forall_and_implicit_args. So either we should s/remove_forall_and_implicit_args/remove_forall/, or the functions calling it should take care to not count the implicit arguments when suppling arg_count. The former solution passes all tests but one; the latter seems complicated.
From what I understand, this occurs in the translation phase. I'm not sure why it's triggered by do notation; I couldn't make it crash with other constructs that (look like they) should crash similarly because of type errors.
Marwes
added a commit
to Marwes/gluon
that referenced
this issue
Aug 5, 2018
Seems that automatically inserted implicit arguments would get put into the normal argument list in this case. Putting them in the implicit argument list instead fixes this.
I found an ICE in the following code:
gluon panics with
"Unexpected type [std.functor.Functor example.Id] -> example.Id () is not a function"
. The panic goes away if I useflat_map
instead ofdo
-notation, or if I remove the implicit parameter onfoo
, so I assume it arises from some interaction between the two features.I'm using
gluon-repl
compiled from source from release 0.8.1.Full stacktrace:
The text was updated successfully, but these errors were encountered: