mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
Merge branch 'trunk' into list_keepIf
This commit is contained in:
commit
ee74ccf6d2
5 changed files with 75 additions and 7 deletions
|
@ -758,7 +758,10 @@ pub fn constrain_expr(
|
||||||
Box::new(Type::Variable(*ext_var)),
|
Box::new(Type::Variable(*ext_var)),
|
||||||
),
|
),
|
||||||
expected.clone(),
|
expected.clone(),
|
||||||
Category::TagApply(name.clone()),
|
Category::TagApply {
|
||||||
|
tag_name: name.clone(),
|
||||||
|
args_count: arguments.len(),
|
||||||
|
},
|
||||||
region,
|
region,
|
||||||
);
|
);
|
||||||
let ast_con = Eq(
|
let ast_con = Eq(
|
||||||
|
|
|
@ -620,13 +620,19 @@ pub fn constrain_expr(
|
||||||
let union_con = Eq(
|
let union_con = Eq(
|
||||||
union_type,
|
union_type,
|
||||||
expected.clone(),
|
expected.clone(),
|
||||||
Category::TagApply(name.clone()),
|
Category::TagApply {
|
||||||
|
tag_name: name.clone(),
|
||||||
|
args_count: arguments.len(),
|
||||||
|
},
|
||||||
region,
|
region,
|
||||||
);
|
);
|
||||||
let ast_con = Eq(
|
let ast_con = Eq(
|
||||||
Type::Variable(*variant_var),
|
Type::Variable(*variant_var),
|
||||||
expected,
|
expected,
|
||||||
Category::TagApply(name.clone()),
|
Category::TagApply {
|
||||||
|
tag_name: name.clone(),
|
||||||
|
args_count: arguments.len(),
|
||||||
|
},
|
||||||
region,
|
region,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -882,12 +882,39 @@ fn add_category<'b>(
|
||||||
|
|
||||||
Lambda => alloc.concat(vec![this_is, alloc.text(" an anonymous function of type:")]),
|
Lambda => alloc.concat(vec![this_is, alloc.text(" an anonymous function of type:")]),
|
||||||
|
|
||||||
TagApply(TagName::Global(name)) => alloc.concat(vec![
|
TagApply {
|
||||||
|
tag_name: TagName::Global(name),
|
||||||
|
args_count: 0,
|
||||||
|
} => alloc.concat(vec![
|
||||||
|
alloc.text("This "),
|
||||||
|
alloc.global_tag_name(name.to_owned()),
|
||||||
|
if name.as_str() == "True" || name.as_str() == "False" {
|
||||||
|
alloc.text(" boolean has the type:")
|
||||||
|
} else {
|
||||||
|
alloc.text(" global tag has the type:")
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
TagApply {
|
||||||
|
tag_name: TagName::Private(name),
|
||||||
|
args_count: 0,
|
||||||
|
} => alloc.concat(vec![
|
||||||
|
alloc.text("This "),
|
||||||
|
alloc.private_tag_name(*name),
|
||||||
|
alloc.text(" private tag has the type:"),
|
||||||
|
]),
|
||||||
|
|
||||||
|
TagApply {
|
||||||
|
tag_name: TagName::Global(name),
|
||||||
|
args_count: _,
|
||||||
|
} => alloc.concat(vec![
|
||||||
alloc.text("This "),
|
alloc.text("This "),
|
||||||
alloc.global_tag_name(name.to_owned()),
|
alloc.global_tag_name(name.to_owned()),
|
||||||
alloc.text(" global tag application has the type:"),
|
alloc.text(" global tag application has the type:"),
|
||||||
]),
|
]),
|
||||||
TagApply(TagName::Private(name)) => alloc.concat(vec![
|
TagApply {
|
||||||
|
tag_name: TagName::Private(name),
|
||||||
|
args_count: _,
|
||||||
|
} => alloc.concat(vec![
|
||||||
alloc.text("This "),
|
alloc.text("This "),
|
||||||
alloc.private_tag_name(*name),
|
alloc.private_tag_name(*name),
|
||||||
alloc.text(" private tag application has the type:"),
|
alloc.text(" private tag application has the type:"),
|
||||||
|
|
|
@ -969,7 +969,7 @@ mod test_reporting {
|
||||||
4│ f Blue
|
4│ f Blue
|
||||||
^^^^
|
^^^^
|
||||||
|
|
||||||
This `Blue` global tag application has the type:
|
This `Blue` global tag has the type:
|
||||||
|
|
||||||
[ Blue ]a
|
[ Blue ]a
|
||||||
|
|
||||||
|
@ -2086,6 +2086,35 @@ mod test_reporting {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn boolean_tag() {
|
||||||
|
report_problem_as(
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
42 + True
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
── TYPE MISMATCH ───────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
The 2nd argument to `add` is not what I expect:
|
||||||
|
|
||||||
|
1│ 42 + True
|
||||||
|
^^^^
|
||||||
|
|
||||||
|
This `True` boolean has the type:
|
||||||
|
|
||||||
|
[ True ]a
|
||||||
|
|
||||||
|
But `add` needs the 2nd argument to be:
|
||||||
|
|
||||||
|
Num a
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn tag_missing() {
|
fn tag_missing() {
|
||||||
report_problem_as(
|
report_problem_as(
|
||||||
|
|
|
@ -927,7 +927,10 @@ pub enum Category {
|
||||||
Lookup(Symbol),
|
Lookup(Symbol),
|
||||||
CallResult(Option<Symbol>),
|
CallResult(Option<Symbol>),
|
||||||
LowLevelOpResult(LowLevel),
|
LowLevelOpResult(LowLevel),
|
||||||
TagApply(TagName),
|
TagApply {
|
||||||
|
tag_name: TagName,
|
||||||
|
args_count: usize,
|
||||||
|
},
|
||||||
Lambda,
|
Lambda,
|
||||||
Uniqueness,
|
Uniqueness,
|
||||||
StrInterpolation,
|
StrInterpolation,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue