apple/pkl · error

notAParameterizableClass

notAParameterizableClass

Error message

notAParameterizableClass

What it means

Raised by the parameterized-type resolution path in `UnresolvedTypeNode.Parameterized#execute`: type arguments were supplied to a base type that is a class but is not parameterizable (it has no type parameters). The error `notAParameterizableClass` carries the class's display name and points at the first type argument's source section.

Source

Thrown at pkl-core/src/main/java/org/pkl/core/ast/type/UnresolvedTypeNode.java:316

          return FunctionNClassTypeNodeGen.create(sourceSection, resolvedTypeArgumentNodes);
        }

        if (clazz.isClassClass()) {
          return ClassClassTypeNodeGen.create(sourceSection, typeArgumentNodes[0].execute(frame));
        }

        if (clazz.isVarArgsClass()) {
          return new VarArgsTypeNode(sourceSection, typeArgumentNodes[0].execute(frame));
        }

        if (clazz.isReferenceClass()) {
          return ReferenceTypeNodeGen.create(
              sourceSection,
              typeArgumentNodes[0].execute(frame),
              typeArgumentNodes[1].execute(frame));
        }

        throw exceptionBuilder()
            .evalError("notAParameterizableClass", clazz.getDisplayName())
            .withSourceSection(typeArgumentNodes[0].sourceSection)
            .build();
      }

      if (baseType instanceof VmTypeAlias typeAlias) {
        var argLength = typeArgumentNodes.length;
        var resolvedTypeArgumentNodes = new TypeNode[argLength];
        for (var i = 0; i < argLength; i++) {
          resolvedTypeArgumentNodes[i] = typeArgumentNodes[i].execute(frame);
        }
        return new TypeAliasTypeNode(sourceSection, typeAlias, resolvedTypeArgumentNodes);
      }

      var module = (VmTyped) baseType;
      throw exceptionBuilder()
          .evalError("notAParameterizableClass", module.getModuleInfo().getModuleName())
          .withSourceSection(typeArgumentNodes[0].sourceSection)

View on GitHub (pinned to f3efcbfc9b)

Solutions

  1. Remove the `<...>` type arguments from the non-parameterizable class.
  2. If you need a parameterized container, use Pkl's generic classes: `List<T>`, `Set<T>`, `Map<K,V>`, `Mapping<K,V>`, `FunctionN<...>`, `Class<T>`.
  3. Verify the class name spelling; you may have meant a different, generic class.
  4. Check the class's definition (typeParameterCount) to confirm whether it takes type arguments.

Example fix

// before
mapping: MyRepo<String> = ...   // MyRepo takes no type args
// after
mapping: Mapping<String, MyRepo> = ...
Defensive patterns

Strategy: validation

Validate before calling

function assertNoTypeArgs(name, args) {
  if (args && args.length) throw new Error(`${name} is not parameterizable; remove <...> arguments`);
}

Type guard

function isParameterizable(cls) { return cls && typeof cls.typeParameterCount === "number" && cls.typeParameterCount > 0; }

Try / catch

try {
  applyTypeArgs(cls, args);
} catch (e) {
  // fall back to non-generic usage
}

Prevention

When it happens

Trigger: Writing `Foo<X>` or a mapping-like use `Foo<K, V>` where `Foo` is a plain class with no type parameters, e.g. `names: String<Int> = ...` or applying `<...>` to any non-generic class.

Common situations: Copy-pasting generic syntax (e.g. from Java-like habits) onto Pkl's non-generic classes; misspelling a generic class name so it resolves to a non-generic one; wrapping Mapping/List types incorrectly around an argument instead of using the right container class.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08). Data as JSON: /api/errors/7b4f1a82f62e0003. Report an issue: GitHub.