Merge pull request #1202 from rtfeldman/constrain_expr2_empty_record

Constrain Expr2::EmptyRecord
This commit is contained in:
Richard Feldman 2021-04-17 14:23:11 -04:00 committed by GitHub
commit 1f78e29b3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

1
.llvmenv Normal file
View file

@ -0,0 +1 @@
10.0.0

View file

@ -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),
}
}

View file

@ -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#"
{}
"#
),
"{}",
)
}