private SemanticInfo GetMatchingSymbolResult()

in src/Kusto.Language/Binder/Binder.cs [1443:1565]


        private SemanticInfo GetMatchingSymbolResult(string name, SyntaxNode location, List<Symbol> matches, bool allowZeroArgumentInvocation)
        {
            if (matches.Count == 1)
            {
                var item = matches[0];
                var resultType = GetResultType(item);

                // check for zero-parameter function invocation not part of a function call node
                if (resultType is FunctionSymbol fn && IsPossibleInvocableFunctionWithoutArgumentList(location))
                {
                    var sig = fn.Signatures.FirstOrDefault(s => s.MinArgumentCount == 0);
                    if (sig != null && allowZeroArgumentInvocation)
                    {
                        var sigResult = GetSignatureResult(sig, EmptyReadOnlyList<Expression>.Instance, EmptyReadOnlyList<TypeSymbol>.Instance);
                        return new SemanticInfo(item, sigResult.Type, expander: sigResult.Expander);
                    }
                    else
                    {
                        var returnType = GetCommonReturnType(fn.Signatures, EmptyReadOnlyList<Expression>.Instance, EmptyReadOnlyList<TypeSymbol>.Instance);
                        return new SemanticInfo(item, returnType, DiagnosticFacts.GetFunctionRequiresArgumentList(name).WithLocation(location));
                    }
                }
                else
                {
                    return CreateSemanticInfo(item);
                }
            }
            else if (matches.Count == 0)
            {
                if (IsFunctionCallName(location))
                {
                    if (_globals.GetAggregate(name) != null && _scopeKind != ScopeKind.Aggregate)
                    {
                        return new SemanticInfo(
                            ErrorSymbol.Instance,
                            DiagnosticFacts.GetAggregateNotAllowedInThisContext(name).WithLocation(location));
                    }
                    else if (_globals.GetPlugIn(name) != null && _scopeKind != ScopeKind.PlugIn)
                    {
                        return new SemanticInfo(
                            ErrorSymbol.Instance,
                            DiagnosticFacts.GetPluginNotAllowedInThisContext(name).WithLocation(location));
                    }
                    else if (IsEvaluateFunctionName(location))
                    {
                        if (PlugIns.GetPlugIn(name) != null)
                        {
                            return new SemanticInfo(
                                ErrorSymbol.Instance,
                                DiagnosticFacts.GetPlugInFunctionIsNotEnabled(name).WithLocation(location));
                        }
                        else
                        {
                            return new SemanticInfo(
                                ErrorSymbol.Instance,
                                DiagnosticFacts.GetPlugInFunctionNotDefined(name).WithLocation(location));
                        }
                    }
                    else if (IsFuzzyUnionOperand(location))
                    {
                        return null;
                    }
                    else if (_pathScope is DatabaseSymbol ds)
                    {
                        if (ds != null && ds.IsOpen)
                        {
                            return new SemanticInfo(new TableSymbol("").WithIsOpen(true));
                        }
                        else
                        {
                            return new SemanticInfo(
                                new TableSymbol("").WithIsOpen(true),
                                DiagnosticFacts.GetNameDoesNotReferToAnyKnownFunction(name).WithLocation(location));
                        }
                    }
                    else if (IsInTabularContext(location))
                    {
                        return new SemanticInfo(
                            new TableSymbol("").WithIsOpen(true),
                            DiagnosticFacts.GetNameDoesNotReferToAnyKnownFunction(name).WithLocation(location));
                    }
                    else
                    {
                        return new SemanticInfo(
                            ErrorSymbol.Instance,
                            DiagnosticFacts.GetNameDoesNotReferToAnyKnownFunction(name).WithLocation(location));
                    }
                }
                else if (IsInTabularContext(location))
                {
                    if (IsFuzzyUnionOperand(location))
                    {
                        return new SemanticInfo(
                            new TableSymbol().WithIsOpen(true),
                            DiagnosticFacts.GetFuzzyUnionOperandNotDefined(name).WithLocation(location));
                    }
                    else if (_pathScope is DatabaseSymbol ds
                        && ds.IsOpen)
                    {
                        return new SemanticInfo(new TableSymbol(name).WithIsOpen(true));
                    }
                    else
                    {
                        return new SemanticInfo(
                            new TableSymbol(name).WithIsOpen(true),
                            DiagnosticFacts.GetNameDoesNotReferToAnyKnownTable(name).WithLocation(location));
                    }
                }
                else
                {
                    return new SemanticInfo(
                        ErrorSymbol.Instance,
                        DiagnosticFacts.GetNameDoesNotReferToAnyKnownItem(name).WithLocation(location));
                }
            }
            else
            {
                return new SemanticInfo(
                    new GroupSymbol(matches.ToList()),
                    ErrorSymbol.Instance,
                    DiagnosticFacts.GetNameRefersToMoreThanOneItem(name).WithLocation(location));
            }
        }