Skip to content

Commit

Permalink
remove difference type
Browse files Browse the repository at this point in the history
  • Loading branch information
aljazerzen committed Jan 27, 2025
1 parent c17725f commit d3c8d0c
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 37 deletions.
3 changes: 0 additions & 3 deletions prqlc/prqlc-parser/src/parser/pr/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ pub enum TyKind {

/// Type of functions with defined params and return types.
Function(Option<TyFunc>),

/// Type that is the largest subtype of `base` while not a subtype of `exclude`.
Difference { base: Box<Ty>, exclude: Box<Ty> },
}

impl TyKind {
Expand Down
5 changes: 0 additions & 5 deletions prqlc/prqlc/src/codegen/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ impl WriteSource for pr::TyKind {
r += &func.return_ty.as_deref().write(opt)?;
Some(r)
}
Difference { base, exclude } => {
let base = base.write(opt.clone())?;
let exclude = exclude.write(opt.clone())?;
Some(format!("{base} - {exclude}"))
}
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions prqlc/prqlc/src/ir/pl/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,6 @@ pub fn fold_type<T: ?Sized + PlFold>(fold: &mut T, ty: Ty) -> Result<Ty> {
})
.transpose()?,
),
TyKind::Difference { base, exclude } => TyKind::Difference {
base: Box::new(fold.fold_type(*base)?),
exclude: Box::new(fold.fold_type(*exclude)?),
},
TyKind::Ident(_) | TyKind::Primitive(_) | TyKind::Singleton(_) => ty.kind,
},
span: ty.span,
Expand Down
2 changes: 1 addition & 1 deletion prqlc/prqlc/src/semantic/resolver/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl pl::PlFold for Resolver<'_> {

// fold function
let func = self.apply_args_to_closure(func, args, named_args)?;
self.fold_function(func, *span)?
self.fold_function(func, *span)?
}

pl::ExprKind::Func(closure) => self.fold_function(closure, *span)?,
Expand Down
6 changes: 1 addition & 5 deletions prqlc/prqlc/src/semantic/resolver/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ use crate::Result;
use crate::{Error, Span, WithErrorInfo};

impl Resolver<'_> {
pub fn fold_function(
&mut self,
closure: Box<Func>,
span: Option<Span>,
) -> Result<Expr> {
pub fn fold_function(&mut self, closure: Box<Func>, span: Option<Span>) -> Result<Expr> {
let closure = self.fold_function_types(closure)?;

log::debug!(
Expand Down
19 changes: 0 additions & 19 deletions prqlc/prqlc/src/semantic/resolver/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,6 @@ impl Resolver<'_> {
TyKind::Array(items_ty)
}

ExprKind::All { within, except } => {
let base = Box::new(Resolver::infer_type(within)?.unwrap());
let exclude = Box::new(Resolver::infer_type(except)?.unwrap());

TyKind::Difference { base, exclude }
}

_ => return Ok(None),
};
Ok(Some(Ty {
Expand Down Expand Up @@ -390,18 +383,6 @@ fn maybe_type_intersection(a: Option<Ty>, b: Option<Ty>) -> Option<Ty> {

pub fn type_intersection(a: Ty, b: Ty) -> Ty {
match (a.kind, b.kind) {
// difference
(TyKind::Difference { base, exclude }, b_kind) => {
let b = Ty { kind: b_kind, ..b };
let base = Box::new(type_intersection(*base, b));
Ty::new(TyKind::Difference { base, exclude })
}
(a_kind, TyKind::Difference { base, exclude }) => {
let a = Ty { kind: a_kind, ..a };
let base = Box::new(type_intersection(a, *base));
Ty::new(TyKind::Difference { base, exclude })
}

(a_kind, b_kind) if a_kind == b_kind => Ty { kind: a_kind, ..a },

// tuple
Expand Down

0 comments on commit d3c8d0c

Please sign in to comment.