diff --git a/src/infer.rs b/src/infer.rs index 8f3ccac..9490e86 100644 --- a/src/infer.rs +++ b/src/infer.rs @@ -383,11 +383,7 @@ impl InferTypes for ast::Expression { ast::Expression::BoolValue(_) => Ok((arg_simple(SimpleType::Bool), scope.clone())), ast::Expression::Literal(Literal { value, .. }) => value.infer_types(scope), ast::Expression::Null { .. } => Ok((arg_simple(SimpleType::Null), scope.clone())), - ast::Expression::ColumnName(ident) => { - let ident = ident.to_owned().into(); - let ty = scope.get_or_err(&ident)?.try_as_argument_type(&ident)?; - Ok((ty.to_owned(), scope.clone())) - } + ast::Expression::ColumnName(ident) => ident.infer_types(scope), ast::Expression::TableAndColumnName(name) => name.infer_types(scope), ast::Expression::Cast(cast) => cast.infer_types(scope), ast::Expression::FunctionCall(fcall) => fcall.infer_types(scope), @@ -412,6 +408,16 @@ impl InferTypes for LiteralValue { } } +impl InferTypes for Ident { + type Type = ArgumentType; + + fn infer_types(&mut self, scope: &ScopeHandle) -> Result<(Self::Type, ScopeHandle)> { + let ident = self.to_owned().into(); + let ty = scope.get_or_err(&ident)?.try_as_argument_type(&ident)?; + Ok((ty.to_owned(), scope.clone())) + } +} + impl InferTypes for ast::TableAndColumnName { type Type = ArgumentType;