From d2306cea52c78c8bd442585cc45eb56486096ea4 Mon Sep 17 00:00:00 2001 From: Tpt Date: Mon, 21 Aug 2023 08:41:50 +0200 Subject: [PATCH] Improves type inference on zero-args functions --- lib/sparopt/src/type_inference.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/sparopt/src/type_inference.rs b/lib/sparopt/src/type_inference.rs index 03960adb..d52476bd 100644 --- a/lib/sparopt/src/type_inference.rs +++ b/lib/sparopt/src/type_inference.rs @@ -182,9 +182,17 @@ pub fn infer_expression_type(expression: &Expression, types: &VariableTypes) -> Expression::FunctionCall(Function::Predicate, _) => { VariableType::NAMED_NODE | VariableType::UNDEF } - Expression::FunctionCall(Function::BNode, _) => { - VariableType::BLANK_NODE | VariableType::UNDEF + Expression::FunctionCall(Function::BNode, args) => { + if args.is_empty() { + VariableType::BLANK_NODE + } else { + VariableType::BLANK_NODE | VariableType::UNDEF + } } + Expression::FunctionCall( + Function::Rand | Function::Now | Function::Uuid | Function::StrUuid, + _, + ) => VariableType::LITERAL, Expression::Or(_) | Expression::And(_) | Expression::Equal(_, _) @@ -203,7 +211,6 @@ pub fn infer_expression_type(expression: &Expression, types: &VariableTypes) -> Function::Str | Function::Lang | Function::LangMatches - | Function::Rand | Function::Abs | Function::Ceil | Function::Floor @@ -228,9 +235,6 @@ pub fn infer_expression_type(expression: &Expression, types: &VariableTypes) -> | Function::Seconds | Function::Timezone | Function::Tz - | Function::Now - | Function::Uuid - | Function::StrUuid | Function::Md5 | Function::Sha1 | Function::Sha256