mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
Unify import params on copied variable
This commit is contained in:
parent
544a5dcfec
commit
625a5425f4
4 changed files with 42 additions and 2 deletions
|
@ -922,6 +922,21 @@ mod cli_run {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(windows, ignore)]
|
||||
fn module_params_different_types() {
|
||||
test_roc_app(
|
||||
"crates/cli/tests/module_params",
|
||||
"different_types.roc",
|
||||
&["42"],
|
||||
&[],
|
||||
&[],
|
||||
"Write something:\n42\n",
|
||||
UseValgrind::No,
|
||||
TestCliCommands::Run,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(windows, ignore)]
|
||||
fn module_params_multiline_pattern() {
|
||||
|
|
3
crates/cli/tests/module_params/Alias.roc
Normal file
3
crates/cli/tests/module_params/Alias.roc
Normal file
|
@ -0,0 +1,3 @@
|
|||
module { passed } -> [exposed]
|
||||
|
||||
exposed = passed
|
14
crates/cli/tests/module_params/different_types.roc
Normal file
14
crates/cli/tests/module_params/different_types.roc
Normal file
|
@ -0,0 +1,14 @@
|
|||
app [main] {
|
||||
cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.15.0/SlwdbJ-3GR7uBWQo6zlmYWNYOxnvo8r6YABXD-45UOw.tar.br",
|
||||
}
|
||||
|
||||
import cli.Stdout
|
||||
import cli.Stdin
|
||||
|
||||
import Alias { passed: Stdin.line } as In
|
||||
import Alias { passed: Stdout.line } as Out
|
||||
|
||||
main =
|
||||
Out.exposed! "Write something:"
|
||||
input = In.exposed!
|
||||
Out.exposed! input
|
|
@ -1403,7 +1403,7 @@ fn solve(
|
|||
}
|
||||
ImportParams(opt_provided, module_id, region) => {
|
||||
match (module_params_vars.get(module_id), opt_provided) {
|
||||
(Some(expected), Some(provided)) => {
|
||||
(Some(expected_og), Some(provided)) => {
|
||||
let actual = either_type_index_to_var(
|
||||
env,
|
||||
rank,
|
||||
|
@ -1415,10 +1415,18 @@ fn solve(
|
|||
*provided,
|
||||
);
|
||||
|
||||
let expected = {
|
||||
// Similar to Lookup, we need to unify on a copy of the module params variable
|
||||
// Otherwise, this import might make it less general than it really is
|
||||
let mut solve_env = env.as_solve_env();
|
||||
let solve_env = &mut solve_env;
|
||||
deep_copy_var_in(solve_env, rank, *expected_og, solve_env.arena)
|
||||
};
|
||||
|
||||
match unify(
|
||||
&mut env.uenv(),
|
||||
actual,
|
||||
*expected,
|
||||
expected,
|
||||
UnificationMode::EQ,
|
||||
Polarity::OF_VALUE,
|
||||
) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue