diff --git a/src/click/types.py b/src/click/types.py
--- a/src/click/types.py
+++ b/src/click/types.py
@@ -63,7 +63,14 @@ def to_info_dict(self) -> t.Dict[str, t.Any]:
         # The class name without the "ParamType" suffix.
         param_type = type(self).__name__.partition("ParamType")[0]
         param_type = param_type.partition("ParameterType")[0]
-        return {"param_type": param_type, "name": self.name}
+
+        # Custom subclasses might not remember to set a name.
+        if hasattr(self, "name"):
+            name = self.name
+        else:
+            name = param_type
+
+        return {"param_type": param_type, "name": name}
 
     def __call__(
         self,

diff --git a/tests/test_info_dict.py b/tests/test_info_dict.py
--- a/tests/test_info_dict.py
+++ b/tests/test_info_dict.py
@@ -266,3 +266,10 @@ def test_context():
         "ignore_unknown_options": False,
         "auto_envvar_prefix": None,
     }
+
+
+def test_paramtype_no_name():
+    class TestType(click.ParamType):
+        pass
+
+    assert TestType().to_info_dict()["name"] == "TestType"

`ParamType` missing `name` errors on `to_info_dict`
When calling `to_info_dict` on a `ParamType` instance which doesn't have a `name` attribute, an exception is raised. While this is a bug in the downstream code, only `to_info_dict` is affected, so the bug often goes unnoticed.

```py3
class TestType(click.ParamType):
    pass

TestType().to_info_dict()
```

```
>       return {"param_type": param_type, "name": self.name}
E       AttributeError: 'TestType' object has no attribute 'name'

src/click/types.py:66: AttributeError
```

It would be nice to have some sort of reasonable fallback. I've put coded such possibility at https://github.com/pallets/click/compare/main...phy1729:fix-ParamType-no-name . I also fixed where the docs neglected to specify `name` in an example.

Environment:

- Python version: Python 3.9.9
- Click version: 8.0.3

