mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-13 09:49:11 +03:00
Fix tuple accessor type printing
This commit is contained in:
parent
de828416bf
commit
303e5bceb3
@ -3801,8 +3801,15 @@ fn adjust_rank_content(
|
||||
rank
|
||||
}
|
||||
|
||||
Tuple(_elems, _ext_var) => {
|
||||
todo!()
|
||||
Tuple(elems, ext_var) => {
|
||||
let mut rank = adjust_rank(subs, young_mark, visit_mark, group_rank, *ext_var);
|
||||
|
||||
for (_, var_index) in elems.iter_all() {
|
||||
let var = subs[var_index];
|
||||
rank = rank.max(adjust_rank(subs, young_mark, visit_mark, group_rank, var));
|
||||
}
|
||||
|
||||
rank
|
||||
}
|
||||
|
||||
TagUnion(tags, ext_var) => {
|
||||
|
@ -1489,6 +1489,14 @@ mod solve_expr {
|
||||
infer_eq("(5, 3.14 )", "( Num *, Float * )*");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tuple_literal_accessor_ty() {
|
||||
infer_eq(".0", "( a )* -> a");
|
||||
infer_eq(".4", "( _, _, _, _, a )* -> a");
|
||||
infer_eq(".5", "( ... 5 omitted, a )* -> a");
|
||||
infer_eq(".200", "( ... 200 omitted, a )* -> a");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn record_arg() {
|
||||
infer_eq("\\rec -> rec.x", "{ x : a }* -> a");
|
||||
|
@ -1227,14 +1227,26 @@ fn write_flat_type<'a>(
|
||||
buf.push_str("( ");
|
||||
|
||||
let mut any_written_yet = false;
|
||||
let mut expected_next_index = 0;
|
||||
|
||||
for (_, var) in sorted_elems {
|
||||
for (index, var) in sorted_elems {
|
||||
if any_written_yet {
|
||||
buf.push_str(", ");
|
||||
} else {
|
||||
any_written_yet = true;
|
||||
}
|
||||
|
||||
if index - expected_next_index > 4 {
|
||||
// Don't write out a large number of _'s - just write out a count
|
||||
buf.push_str(&format!("... {} omitted, ", index - expected_next_index));
|
||||
} else if index - expected_next_index > 1 {
|
||||
// Write out a bunch of _'s
|
||||
for _ in expected_next_index..index {
|
||||
buf.push_str("_, ");
|
||||
}
|
||||
}
|
||||
expected_next_index = index + 1;
|
||||
|
||||
write_content(
|
||||
env,
|
||||
ctx,
|
||||
|
Loading…
Reference in New Issue
Block a user