implement type inference for literals
This commit is contained in:
parent
f03c777e28
commit
8c16a94be4
|
@ -292,7 +292,7 @@ impl Context {
|
||||||
return expr.clone();
|
return expr.clone();
|
||||||
}
|
}
|
||||||
match &expr.kind {
|
match &expr.kind {
|
||||||
typed_ir::ExprKind::Literal(_) => todo!(),
|
typed_ir::ExprKind::Literal(lit) => expr.clone().with_type(lit.typ),
|
||||||
// we can not see beyond this expression right now
|
// we can not see beyond this expression right now
|
||||||
typed_ir::ExprKind::Path(_) => expr.clone(),
|
typed_ir::ExprKind::Path(_) => expr.clone(),
|
||||||
typed_ir::ExprKind::Call {
|
typed_ir::ExprKind::Call {
|
||||||
|
@ -372,7 +372,11 @@ impl Context {
|
||||||
expr: &typed_ir::Expr,
|
expr: &typed_ir::Expr,
|
||||||
) -> std::fmt::Result {
|
) -> std::fmt::Result {
|
||||||
let expr_pretty = match &expr.kind {
|
let expr_pretty = match &expr.kind {
|
||||||
typed_ir::ExprKind::Literal(_) => todo!(),
|
typed_ir::ExprKind::Literal(lit) => {
|
||||||
|
let mut lit_str = String::new();
|
||||||
|
self.types.pretty_value(&mut lit_str, lit)?;
|
||||||
|
lit_str
|
||||||
|
}
|
||||||
typed_ir::ExprKind::Path(path) => format!("sig_{}", path.0),
|
typed_ir::ExprKind::Path(path) => format!("sig_{}", path.0),
|
||||||
typed_ir::ExprKind::Call {
|
typed_ir::ExprKind::Call {
|
||||||
called,
|
called,
|
||||||
|
|
|
@ -43,7 +43,7 @@ pub struct FnSig {
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ElabData {
|
pub struct ElabData {
|
||||||
typ: Type,
|
pub typ: Type,
|
||||||
value: ElabValue,
|
value: ElabValue,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue