apple/pkl · error · VmReferenceAccessError
externalMember
Error message
externalMember
What it means
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.
Source
Thrown at pkl-core/src/main/java/org/pkl/core/runtime/VmReference.java:260
if (clazz.getPClass().isSubclassOf(baseModule) && property.equals("output")) {
throw new VmReferenceAccessError(
new PType.Class(baseModule), VmReferenceAccessErrorType.EXTERNAL_CLASS);
}
// dot access on `Reference<D, Null>` gives `Reference<D, Null>`
if (clazz.getPClass().getInfo() == PClassInfo.Null) {
result.add(clazz);
return;
}
var prop = clazz.getPClass().getAllProperties().get(property);
if (prop == null) {
throw new VmReferenceAccessError(type, VmReferenceAccessErrorType.CANNOT_FIND_MEMBER);
}
// restriction: cannot reference external properties
if (prop.isExternal()) {
throw new VmReferenceAccessError(type, VmReferenceAccessErrorType.EXTERNAL_MEMBER);
}
normalizeTypes(
prop.getType(), result, clazz, new PType.Class(clazz.getPClass().getModuleClass()));
}
private static PClassInfo<?> getClassInfo(Object value) {
if (value instanceof VmValue vmValue) return vmValue.getVmClass().getPClassInfo();
if (value instanceof String) return PClassInfo.String;
if (value instanceof Boolean) return PClassInfo.Boolean;
if (value instanceof Long) return PClassInfo.Int;
if (value instanceof Double) return PClassInfo.Float;
throw new PklBugException("Not a Pkl value: " + value.getClass());
}
@SuppressWarnings("DuplicatedCode")
private static void getCandidateSubscriptType(PType type, Object key, Set<PType> result) {
if (type == PType.UNKNOWN) {View on GitHub (pinned to f3efcbfc9b)
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.
Example fix
// before x = someObj.someExternalProp // after (in subclass) someExternalProp: Int = 42 x = this.someExternalProp
Defensive patterns
Strategy: type-guard
Validate before calling
// Pkl: skip external properties when referencing
prop = obj.getClass().getAllProperties()[name]
if (prop != null && !prop.isExternal()) { /* safe to reference */ } Type guard
// Pkl
function isReferenceable(obj: Typed, name: String): Boolean {
val p = obj.getClass().getAllProperties()[name]
return p != null && !p.isExternal
} Try / catch
try {
eval(src);
} catch (EvalException e) {
if (e.getMessage().contains("externalMember")) {
// override the external property concretely or avoid referencing it
}
} Prevention
- 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.
When it happens
Trigger: Referencing a property marked external (e.g. certain base-module built-ins) via property-reference access.
Common situations: Referencing built-in external properties of base classes; subclassing library classes and referencing inherited external declarations.
Related errors
- cannotFindMember
- defaultMember
- defaultMember/cannotFindMember
- cannotFindMember
- cannotFindPropertyInObjectNoHint
AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08).
Data as JSON: /api/errors/31916c977372e5e4.
Report an issue: GitHub.