{"record":{"id":"31916c977372e5e4","repo":"apple/pkl","slug":"externalmember","errorCode":null,"errorMessage":"externalMember","messagePattern":"externalMember","errorType":"error_code","errorClass":"VmReferenceAccessError","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/runtime/VmReference.java","lineNumber":260,"sourceCode":"    if (clazz.getPClass().isSubclassOf(baseModule) && property.equals(\"output\")) {\n      throw new VmReferenceAccessError(\n          new PType.Class(baseModule), VmReferenceAccessErrorType.EXTERNAL_CLASS);\n    }\n\n    // dot access on `Reference<D, Null>` gives `Reference<D, Null>`\n    if (clazz.getPClass().getInfo() == PClassInfo.Null) {\n      result.add(clazz);\n      return;\n    }\n\n    var prop = clazz.getPClass().getAllProperties().get(property);\n    if (prop == null) {\n      throw new VmReferenceAccessError(type, VmReferenceAccessErrorType.CANNOT_FIND_MEMBER);\n    }\n\n    // restriction: cannot reference external properties\n    if (prop.isExternal()) {\n      throw new VmReferenceAccessError(type, VmReferenceAccessErrorType.EXTERNAL_MEMBER);\n    }\n\n    normalizeTypes(\n        prop.getType(), result, clazz, new PType.Class(clazz.getPClass().getModuleClass()));\n  }\n\n  private static PClassInfo<?> getClassInfo(Object value) {\n    if (value instanceof VmValue vmValue) return vmValue.getVmClass().getPClassInfo();\n    if (value instanceof String) return PClassInfo.String;\n    if (value instanceof Boolean) return PClassInfo.Boolean;\n    if (value instanceof Long) return PClassInfo.Int;\n    if (value instanceof Double) return PClassInfo.Float;\n    throw new PklBugException(\"Not a Pkl value: \" + value.getClass());\n  }\n\n  @SuppressWarnings(\"DuplicatedCode\")\n  private static void getCandidateSubscriptType(PType type, Object key, Set<PType> result) {\n    if (type == PType.UNKNOWN) {","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/runtime/VmReference.java#L242-L278","documentation":"Raised when a referenced property exists but is declared `external` (abstract/external in Pkl semantics — implemented by the runtime, not defined in Pkl). External properties cannot be referenced through the Reference property-type machinery.","triggerScenarios":"Referencing a property marked external (e.g. certain base-module built-ins) via property-reference access.","commonSituations":"Referencing built-in external properties of base classes; subclassing library classes and referencing inherited external declarations.","solutions":["Do not reference the external property directly; use a concrete override or a non-external property.","Override the property with a concrete definition in your subclass, then reference your property.","Restructure so the needed value is computed into a normal property.","Consult the class docs to find the concrete equivalent property."],"exampleFix":"// before\nx = someObj.someExternalProp\n// after (in subclass)\nsomeExternalProp: Int = 42\nx = this.someExternalProp","handlingStrategy":"type-guard","validationCode":"// Pkl: skip external properties when referencing\nprop = obj.getClass().getAllProperties()[name]\nif (prop != null && !prop.isExternal()) { /* safe to reference */ }","typeGuard":"// Pkl\nfunction isReferenceable(obj: Typed, name: String): Boolean {\n  val p = obj.getClass().getAllProperties()[name]\n  return p != null && !p.isExternal\n}","tryCatchPattern":"try {\n  eval(src);\n} catch (EvalException e) {\n  if (e.getMessage().contains(\"externalMember\")) {\n    // override the external property concretely or avoid referencing it\n  }\n}","preventionTips":["Override external properties with concrete definitions before referencing them.","Prefer your own non-external properties in subclass APIs.","Check base-class docs for which members are external/abstract."],"tags":["pkl","external-property","reference","member-access"],"backgroundTag":"external-member-access","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"}