MCPcopy Create free account
hub / github.com/PRQL/prql / fold_type

Method fold_type

prqlc/prqlc/src/semantic/resolver/expr.rs:18–44  ·  view source on GitHub ↗
(&mut self, ty: Ty)

Source from the content-addressed store, hash-verified

16 }
17
18 fn fold_type(&mut self, ty: Ty) -> Result<Ty> {
19 Ok(match ty.kind {
20 TyKind::Ident(ident) => {
21 self.root_mod.module.shadow(NS_THIS);
22 self.root_mod.module.shadow(NS_THAT);
23
24 let fq_ident = self.resolve_ident(&ident)?;
25
26 let decl = self.root_mod.module.get(&fq_ident).unwrap();
27 let decl_ty = decl.kind.as_ty().ok_or_else(|| {
28 Error::new(Reason::Expected {
29 who: None,
30 expected: "a type".to_string(),
31 found: decl.to_string(),
32 })
33 })?;
34 let mut ty = decl_ty.clone();
35 ty.name = ty.name.or(Some(fq_ident.name));
36
37 self.root_mod.module.unshadow(NS_THIS);
38 self.root_mod.module.unshadow(NS_THAT);
39
40 ty
41 }
42 _ => pl::fold_type(self, ty)?,
43 })
44 }
45
46 fn fold_var_def(&mut self, var_def: pl::VarDef) -> Result<pl::VarDef> {
47 let value = match var_def.value {

Callers 2

fold_statementsMethod · 0.45
fold_var_defMethod · 0.45

Calls 5

fold_typeFunction · 0.85
shadowMethod · 0.80
resolve_identMethod · 0.80
unshadowMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected