Improves type inference on zero-args functions

pull/612/head
Tpt 1 year ago committed by Thomas Tanon
parent 9e76323e2b
commit d2306cea52
  1. 14
      lib/sparopt/src/type_inference.rs

@ -182,9 +182,17 @@ pub fn infer_expression_type(expression: &Expression, types: &VariableTypes) ->
Expression::FunctionCall(Function::Predicate, _) => { Expression::FunctionCall(Function::Predicate, _) => {
VariableType::NAMED_NODE | VariableType::UNDEF VariableType::NAMED_NODE | VariableType::UNDEF
} }
Expression::FunctionCall(Function::BNode, _) => { Expression::FunctionCall(Function::BNode, args) => {
if args.is_empty() {
VariableType::BLANK_NODE
} else {
VariableType::BLANK_NODE | VariableType::UNDEF VariableType::BLANK_NODE | VariableType::UNDEF
} }
}
Expression::FunctionCall(
Function::Rand | Function::Now | Function::Uuid | Function::StrUuid,
_,
) => VariableType::LITERAL,
Expression::Or(_) Expression::Or(_)
| Expression::And(_) | Expression::And(_)
| Expression::Equal(_, _) | Expression::Equal(_, _)
@ -203,7 +211,6 @@ pub fn infer_expression_type(expression: &Expression, types: &VariableTypes) ->
Function::Str Function::Str
| Function::Lang | Function::Lang
| Function::LangMatches | Function::LangMatches
| Function::Rand
| Function::Abs | Function::Abs
| Function::Ceil | Function::Ceil
| Function::Floor | Function::Floor
@ -228,9 +235,6 @@ pub fn infer_expression_type(expression: &Expression, types: &VariableTypes) ->
| Function::Seconds | Function::Seconds
| Function::Timezone | Function::Timezone
| Function::Tz | Function::Tz
| Function::Now
| Function::Uuid
| Function::StrUuid
| Function::Md5 | Function::Md5
| Function::Sha1 | Function::Sha1
| Function::Sha256 | Function::Sha256

Loading…
Cancel
Save