apple/pkl · error

internalStdLibClass

internalStdLibClass

Error message

internalStdLibClass (VarArgs)

What it means

The VarArgs class is an internal stdlib class that cannot be evaluated as a value type at runtime. This node throws an evalError("internalStdLibClass", "VarArgs") attached to the type's header section when execution reaches it.

Solutions

  1. Use `varargs` only in function parameter positions where the language permits it.
  2. Replace any VarArgs-typed annotation with a concrete type like `List<T>` or `Array`.
  3. If you need variadic behavior in user code, accept `List`/`Array` parameters instead.
  4. Avoid importing or re-exporting internal stdlib classes.

Example fix

// before
f: (varargs) -> Any = ...
prop: VarArgs = ...

// after
prop: List<Any> = List(1, 2, 3)
Defensive patterns

Strategy: validation

Validate before calling

// reject varargs in user-facing type positions before evaluation
if (typeName == "varargs") throw "varargs is only valid in function parameter lists"

Prevention

When it happens

Trigger: User code references the internal `varargs` type in a position where it must be evaluated (e.g. as a value annotation or in a context requiring a concrete class), rather than only as a variadic parameter declaration inside a method/function signature.

Common situations: Copying stdlib function signatures and accidentally exposing `varargs` in a public annotation; writing a type alias or property type that names VarArgs; tooling generating signatures from stdlib metadata.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at pkl-core/src/main/java/org/pkl/core/ast/type/TypeNode.java:2406

  public static class VarArgsTypeNode extends ObjectSlotTypeNode {
    @Child private TypeNode elementTypeNode;

    public VarArgsTypeNode(SourceSection sourceSection, TypeNode elementTypeNode) {

      super(sourceSection);
      this.elementTypeNode = elementTypeNode;
    }

    @Override
    public @Nullable Object createDefaultValue(
        VirtualFrame frame,
        VmLanguage language,
        SourceSection headerSection,
        String qualifiedName) {

      CompilerDirectives.transferToInterpreter();
      throw exceptionBuilder()
          .evalError("internalStdLibClass", "VarArgs")
          .withSourceSection(headerSection)
          .build();
    }

    @Override
    protected final PType doExport() {
      return new PType.Class(BaseModule.getVarArgsClass().export(), elementTypeNode.doExport());
    }

    @Override
    protected Object executeLazily(VirtualFrame frame, Object value) {
      CompilerDirectives.transferToInterpreter();
      throw exceptionBuilder().evalError("internalStdLibClass", "VarArgs").build();
    }

    @Override
    public boolean doIsEquivalentTo(TypeNode other) {

View on GitHub (pinned to f3efcbfc9b)