{"record":{"id":"cf73d38822a5e098","repo":"apple/pkl","slug":"wrongtypeargumentcount-cf73d3","errorCode":"wrongTypeArgumentCount","errorMessage":"wrongTypeArgumentCount (expected, actual)","messagePattern":"wrongTypeArgumentCount \\(expected, actual\\)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/type/TypeNode.java","lineNumber":2752,"sourceCode":"\n  public static final class TypeAliasTypeNode extends TypeNode {\n    private final VmTypeAlias typeAlias;\n    private final TypeNode[] typeArgumentNodes;\n    @Child private TypeNode aliasedTypeNode;\n\n    public TypeAliasTypeNode(\n        SourceSection sourceSection, VmTypeAlias typeAlias, TypeNode[] typeArgumentNodes) {\n      super(sourceSection);\n\n      if (!typeAlias.isInitialized()) {\n        CompilerDirectives.transferToInterpreter();\n        throw exceptionBuilder().evalError(\"cyclicTypeAlias\").build();\n      }\n\n      if (typeArgumentNodes.length > 0\n          && typeArgumentNodes.length != typeAlias.getTypeParameterCount()) {\n        CompilerDirectives.transferToInterpreter();\n        throw exceptionBuilder()\n            .evalError(\n                \"wrongTypeArgumentCount\",\n                typeAlias.getTypeParameterCount(),\n                typeArgumentNodes.length)\n            .build();\n      }\n\n      this.typeAlias = typeAlias;\n      this.typeArgumentNodes = typeArgumentNodes;\n      aliasedTypeNode = typeAlias.instantiate(typeArgumentNodes);\n      aliasedTypeNode.accept(\n          node -> {\n            if (node instanceof ValidatingObjectSlotTypeNode typeNode) {\n              typeNode.validate(this);\n            }\n            return true;\n          });\n    }","sourceCodeStart":2734,"sourceCodeEnd":2770,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/type/TypeNode.java#L2734-L2770","documentation":"When constructing a TypeAliasTypeNode for a parameterized type alias, the number of supplied type-argument nodes must equal the alias's type parameter count. If at least one argument is given but the counts differ, Pkl throws an evalError `wrongTypeArgumentCount(expected, actual)` with the expected and actual counts.","triggerScenarios":"Writing `Foo<Int, String>` where `typealias Foo<T>` takes one parameter, or `Pair<Int>` where Pair expects two; programmatically building typecheck nodes with a mismatched typeArgumentNodes array.","commonSituations":"Copy-pasted generic applications missing or extra type arguments; misremembering a stdlib alias's arity (e.g. `List<Int, String>`); refactor changing a parameter count without updating all usages.","solutions":["Match the argument count to the alias's declared type parameters (read the alias definition)","Remove extra type arguments or add missing ones","Replace a one-parameter alias with a class if you need multiple parameters","Search usages of the alias after changing its parameter count"],"exampleFix":"// before\ntypealias Box<T> = ...\nval b: Box<Int, String> = ...\n// after\nval b: Box<Int> = ...","handlingStrategy":"type-guard","validationCode":"// pkl: typealias Box<T> — count <T> params and apply exactly that many arguments","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check the alias declaration's <T,...> parameter list before applying type arguments","Update all application sites when changing a generic alias's parameter count","Avoid guessing stdlib generic arity — consult the API docs"],"tags":["pkl","generics","type-arguments"],"backgroundTag":"wrong-type-argument-count","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}