mirror of
https://github.com/roc-lang/roc.git
synced 2025-11-01 13:34:15 +00:00
Merge remote-tracking branch 'origin/trunk' into fix-nested-imports
This commit is contained in:
commit
c45e3ec4b4
93 changed files with 3258 additions and 4416 deletions
|
|
@ -4024,7 +4024,8 @@ mod solve_expr {
|
|||
{ x, y }
|
||||
"#
|
||||
),
|
||||
"{ x : I64, y ? Bool }* -> { x : I64, y : Bool }",
|
||||
// TODO: when structural types unify with alias, they should take the alias name
|
||||
"{ x : I64, y ? [False, True] }* -> { x : I64, y : Bool }",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -6484,6 +6485,7 @@ mod solve_expr {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "TODO: fix unification of derived types"]
|
||||
fn encode_record() {
|
||||
infer_queries!(
|
||||
indoc!(
|
||||
|
|
@ -6503,6 +6505,7 @@ mod solve_expr {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "TODO: fix unification of derived types"]
|
||||
fn encode_record_with_nested_custom_impl() {
|
||||
infer_queries!(
|
||||
indoc!(
|
||||
|
|
@ -7066,7 +7069,7 @@ mod solve_expr {
|
|||
"#
|
||||
),
|
||||
"F U8 Str",
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -7083,7 +7086,7 @@ mod solve_expr {
|
|||
"#
|
||||
),
|
||||
"F U8 Str -> F U8 Str",
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -7099,6 +7102,188 @@ mod solve_expr {
|
|||
"#
|
||||
),
|
||||
"F * {}* -> F * Str",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn polymorphic_lambda_set_specialization() {
|
||||
infer_queries!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
F has f : a -> (b -> {}) | a has F, b has G
|
||||
G has g : b -> {} | b has G
|
||||
|
||||
Fo := {}
|
||||
f = \@Fo {} -> g
|
||||
#^{-1}
|
||||
|
||||
Go := {}
|
||||
g = \@Go {} -> {}
|
||||
#^{-1}
|
||||
|
||||
main = (f (@Fo {})) (@Go {})
|
||||
# ^
|
||||
# ^^^^^^^^^^
|
||||
"#
|
||||
),
|
||||
&[
|
||||
"Fo#f(10) : Fo -[[f(10)]]-> (b -[[] + b:g(8):1]-> {}) | b has G",
|
||||
"Go#g(11) : Go -[[g(11)]]-> {}",
|
||||
"Fo#f(10) : Fo -[[f(10)]]-> (Go -[[g(11)]]-> {})",
|
||||
"f (@Fo {}) : Go -[[g(11)]]-> {}",
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn polymorphic_lambda_set_specialization_bound_output() {
|
||||
infer_queries!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
F has f : a -> ({} -> b) | a has F, b has G
|
||||
G has g : {} -> b | b has G
|
||||
|
||||
Fo := {}
|
||||
f = \@Fo {} -> g
|
||||
#^{-1}
|
||||
|
||||
Go := {}
|
||||
g = \{} -> @Go {}
|
||||
#^{-1}
|
||||
|
||||
main =
|
||||
foo = 1
|
||||
@Go it = (f (@Fo {})) {}
|
||||
# ^
|
||||
# ^^^^^^^^^^
|
||||
|
||||
{foo, it}
|
||||
"#
|
||||
),
|
||||
&[
|
||||
"Fo#f(10) : Fo -[[f(10)]]-> ({} -[[] + b:g(8):1]-> b) | b has G",
|
||||
"Go#g(11) : {} -[[g(11)]]-> Go",
|
||||
"Fo#f(10) : Fo -[[f(10)]]-> ({} -[[g(11)]]-> Go)",
|
||||
"f (@Fo {}) : {} -[[g(11)]]-> Go",
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn polymorphic_lambda_set_specialization_with_let_generalization() {
|
||||
infer_queries!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
F has f : a -> (b -> {}) | a has F, b has G
|
||||
G has g : b -> {} | b has G
|
||||
|
||||
Fo := {}
|
||||
f = \@Fo {} -> g
|
||||
#^{-1}
|
||||
|
||||
Go := {}
|
||||
g = \@Go {} -> {}
|
||||
#^{-1}
|
||||
|
||||
main =
|
||||
h = f (@Fo {})
|
||||
# ^ ^
|
||||
h (@Go {})
|
||||
# ^
|
||||
"#
|
||||
),
|
||||
&[
|
||||
"Fo#f(10) : Fo -[[f(10)]]-> (b -[[] + b:g(8):1]-> {}) | b has G",
|
||||
"Go#g(11) : Go -[[g(11)]]-> {}",
|
||||
// TODO SERIOUS: Let generalization is broken here, and this is NOT correct!!
|
||||
// Two problems:
|
||||
// - 1. `{}` always has its rank adjusted to the toplevel, which forces the rest
|
||||
// of the type to the toplevel, but that is NOT correct here!
|
||||
// - 2. During solving lambda set compaction cannot happen until an entire module
|
||||
// is solved, which forces resolved-but-not-yet-compacted lambdas in
|
||||
// unspecialized lambda sets to pull the rank into a lower, non-generalized
|
||||
// rank. Special-casing for that is a TERRIBLE HACK that interferes very
|
||||
// poorly with (1)
|
||||
//
|
||||
// We are BLOCKED on https://github.com/rtfeldman/roc/issues/3207 to make this work
|
||||
// correctly!
|
||||
// See also https://github.com/rtfeldman/roc/pull/3175, a separate, but similar problem.
|
||||
"h : Go -[[g(11)]]-> {}",
|
||||
"Fo#f(10) : Fo -[[f(10)]]-> (Go -[[g(11)]]-> {})",
|
||||
"h : Go -[[g(11)]]-> {}",
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn polymorphic_lambda_set_specialization_with_let_generalization_unapplied() {
|
||||
infer_queries!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
F has f : a -> (b -> {}) | a has F, b has G
|
||||
G has g : b -> {} | b has G
|
||||
|
||||
Fo := {}
|
||||
f = \@Fo {} -> g
|
||||
#^{-1}
|
||||
|
||||
Go := {}
|
||||
g = \@Go {} -> {}
|
||||
#^{-1}
|
||||
|
||||
main =
|
||||
#^^^^{-1}
|
||||
h = f (@Fo {})
|
||||
# ^ ^
|
||||
h
|
||||
"#
|
||||
),
|
||||
&[
|
||||
"Fo#f(10) : Fo -[[f(10)]]-> (b -[[] + b:g(8):1]-> {}) | b has G",
|
||||
"Go#g(11) : Go -[[g(11)]]-> {}",
|
||||
"main : b -[[] + b:g(8):1]-> {} | b has G",
|
||||
"h : b -[[] + b:g(8):1]-> {} | b has G",
|
||||
"Fo#f(10) : Fo -[[f(10)]]-> (b -[[] + b:g(8):1]-> {}) | b has G",
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn polymorphic_lambda_set_specialization_with_deep_specialization_and_capture() {
|
||||
infer_queries!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
F has f : a, b -> ({} -> ({} -> {})) | a has F, b has G
|
||||
G has g : b -> ({} -> {}) | b has G
|
||||
|
||||
Fo := {}
|
||||
f = \@Fo {}, b -> \{} -> g b
|
||||
#^{-1}
|
||||
|
||||
Go := {}
|
||||
g = \@Go {} -> \{} -> {}
|
||||
#^{-1}
|
||||
|
||||
main =
|
||||
(f (@Fo {}) (@Go {})) {}
|
||||
# ^
|
||||
"#
|
||||
),
|
||||
&[
|
||||
"Fo#f(10) : Fo, b -[[f(10)]]-> ({} -[[13(13) b]]-> ({} -[[] + b:g(8):2]-> {})) | b has G",
|
||||
"Go#g(11) : Go -[[g(11)]]-> ({} -[[14(14)]]-> {})",
|
||||
"Fo#f(10) : Fo, Go -[[f(10)]]-> ({} -[[13(13) Go]]-> ({} -[[14(14)]]-> {}))",
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue