diff --git a/crates/cli/tests/cli_tests.rs b/crates/cli/tests/cli_tests.rs index 21a96b8d6e..faf159ff61 100644 --- a/crates/cli/tests/cli_tests.rs +++ b/crates/cli/tests/cli_tests.rs @@ -1434,6 +1434,20 @@ mod cli_tests { .run() .assert_clean_success(); } + + #[test] + fn module_params_effectful_param() { + let cli_check = ExecCli::new( + CMD_CHECK, + file_from_root( + "crates/cli/tests/test-projects/module_params", + "effect_module.roc", + ), + ); + + let cli_check_out = cli_check.run(); + cli_check_out.assert_clean_success(); + } } #[cfg(feature = "wasm32-cli-run")] diff --git a/crates/cli/tests/test-projects/module_params/effect_module.roc b/crates/cli/tests/test-projects/module_params/effect_module.roc new file mode 100644 index 0000000000..8728f52e55 --- /dev/null +++ b/crates/cli/tests/test-projects/module_params/effect_module.roc @@ -0,0 +1,3 @@ +module { stdout! } -> [log!] + +log! = \msg, level -> stdout! "$(level):$(msg)" diff --git a/crates/compiler/load_internal/src/file.rs b/crates/compiler/load_internal/src/file.rs index 3168bbae76..22bbdc3687 100644 --- a/crates/compiler/load_internal/src/file.rs +++ b/crates/compiler/load_internal/src/file.rs @@ -2269,18 +2269,18 @@ fn update<'a>( state.fx_mode = FxMode::PurityInference; } } - Builtin { .. } | Module { .. } => { + Builtin { .. } => { if header.is_root_module { debug_assert!(matches!(state.platform_path, PlatformPath::NotSpecified)); state.platform_path = PlatformPath::RootIsModule; } } - Hosted { exposes, .. } => { + Hosted { exposes, .. } | Module { exposes, .. } => { if header.is_root_module { debug_assert!(matches!(state.platform_path, PlatformPath::NotSpecified)); state.platform_path = PlatformPath::RootIsHosted; } - + // WARNING: This will be bypassed if we export a record of effectful functions. This is a temporary hacky method if exposes .iter() .any(|exposed| exposed.value.is_effectful_fn()) diff --git a/crates/compiler/unify/src/unify.rs b/crates/compiler/unify/src/unify.rs index bc23230ad5..815570ec69 100644 --- a/crates/compiler/unify/src/unify.rs +++ b/crates/compiler/unify/src/unify.rs @@ -3345,6 +3345,17 @@ fn unify_flat_type( outcome } + (Func(args, closure, ret, fx), EffectfulFunc) => { + let mut outcome = unify_pool(env, pool, *fx, Variable::EFFECTFUL, ctx.mode); + + outcome.union(merge( + env, + ctx, + Structure(Func(*args, *closure, *ret, Variable::EFFECTFUL)), + )); + + outcome + } (FunctionOrTagUnion(tag_names, tag_symbols, ext), Func(args, closure, ret, fx)) => { unify_function_or_tag_union_and_func( env,