Skip to content

Commit 6e3cf9f

Browse files
author
Kusto Build System
committed
Auto-sync from Azure-Kusto-Service
1 parent 904f4a9 commit 6e3cf9f

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/Kusto.Language/Operators.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,24 @@ private static OperatorSymbol StringBinary(OperatorKind kind)
4444

4545
public static readonly OperatorSymbol UnaryMinus =
4646
new OperatorSymbol(OperatorKind.UnaryMinus,
47-
new Signature(ReturnTypeKind.Parameter0, new Parameter("operand", ParameterTypeKind.Summable)),
47+
new Signature(UnaryReturnType, Tabularity.Scalar, new Parameter("operand", ParameterTypeKind.Summable)),
4848
new Signature(ScalarTypes.Dynamic, new Parameter("operand", ScalarTypes.Dynamic)));
4949

5050
public static readonly OperatorSymbol UnaryPlus =
5151
new OperatorSymbol(OperatorKind.UnaryPlus,
52-
new Signature(ReturnTypeKind.Parameter0, new Parameter("operand", ParameterTypeKind.Summable)),
52+
new Signature(UnaryReturnType, Tabularity.Scalar, new Parameter("operand", ParameterTypeKind.Summable)),
5353
new Signature(ScalarTypes.Dynamic, new Parameter("operand", ScalarTypes.Dynamic)));
5454

55+
private static TypeSymbol UnaryReturnType(CustomReturnTypeContext context)
56+
{
57+
// unary operator folds into constants w/o promotion
58+
return context.Arguments.Count == 1
59+
&& context.ArgumentTypes[0] == ScalarTypes.Int
60+
&& !context.Arguments[0].IsConstant
61+
? ScalarTypes.Long
62+
: context.ArgumentTypes[0];
63+
}
64+
5565
public static readonly OperatorSymbol And =
5666
new OperatorSymbol(OperatorKind.And,
5767
new Signature(ScalarTypes.Bool, new Parameter("left", ScalarTypes.Bool), new Parameter("right", ScalarTypes.Bool)),

0 commit comments

Comments
 (0)