mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 16:21:11 +00:00
Merge pull request #1202 from rtfeldman/constrain_expr2_empty_record
Constrain Expr2::EmptyRecord
This commit is contained in:
commit
1f78e29b3c
3 changed files with 22 additions and 2 deletions
1
.llvmenv
Normal file
1
.llvmenv
Normal file
|
@ -0,0 +1 @@
|
|||
10.0.0
|
|
@ -18,11 +18,17 @@ pub enum Constraint {
|
|||
// And(Vec<Constraint>),
|
||||
}
|
||||
|
||||
pub fn constrain_expr(env: &mut Env, expr: &Expr2, expected: Expected<Type2>) -> Constraint {
|
||||
pub fn constrain_expr(
|
||||
env: &mut Env,
|
||||
expr: &Expr2,
|
||||
expected: Expected<Type2>,
|
||||
region: Region,
|
||||
) -> Constraint {
|
||||
use Constraint::*;
|
||||
|
||||
match expr {
|
||||
Expr2::Str(_) => Eq(str_type(env.pool), expected, Category::Str, Region::zero()),
|
||||
Expr2::EmptyRecord => Eq(Type2::EmptyRec, expected, Category::Record, region),
|
||||
Expr2::Str(_) => Eq(str_type(env.pool), expected, Category::Str, region),
|
||||
_ => todo!("implement constaints for {:?}", expr),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,6 +86,7 @@ fn infer_eq(actual: &str, expected_str: &str) {
|
|||
&mut env,
|
||||
&expr,
|
||||
Expected::NoExpectation(Type2::Variable(var)),
|
||||
Region::zero(),
|
||||
);
|
||||
|
||||
let Env {
|
||||
|
@ -129,3 +130,15 @@ fn constrain_str() {
|
|||
"Str",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn constrain_empty_record() {
|
||||
infer_eq(
|
||||
indoc!(
|
||||
r#"
|
||||
{}
|
||||
"#
|
||||
),
|
||||
"{}",
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue