public TypeSpecifier(TypeSpecifier returnType, TypeSpecifier[] parameterTypes)
        {
            if (returnType == null)
            {
                throw new OracularException ("return type invalid");
            }

            if (parameterTypes == null)
            {
                throw new OracularException ("parameter types invalid");
            }

            this.Type = SpecType.Function;
            this.ReturnType = returnType;
            this.ParameterTypes = parameterTypes;
        }
 public static TypeSpecifier GetFunction(TypeSpecifier returnType, TypeSpecifier[] parameterTypes)
 {
     return new TypeSpecifier (returnType, parameterTypes);
 }
        public TypeSpecifier Coalesce(TypeSpecifier other)
        {
            if (Type == SpecType.Any)
            {
                if (other.Type == SpecType.Any)
                {
                    // both any, return any
                    return this;
                }

                // this is any, defer to other
                return other;
            }

            if (Type != other.Type)
            {
                // distinct types, invalid
                return null;
            }

            if (Type == SpecType.Table)
            {
                // both table types, check table names
                return Table == other.Table ? this : null;
            }

            // same type
            return this;
        }