apple/pkl · error
redundantHiddenModifier
redundantHiddenModifier
Error message
redundantHiddenModifier
What it means
`local` members are already confined to their enclosing object and invisible outside it, so adding `hidden` is meaningless. AstBuilder rejects the combination `local hidden` with `redundantHiddenModifier`, pointing at the HIDDEN modifier (AstBuilder.java:3016).
Source
Thrown at pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java:3016
throw exceptionBuilder()
.evalError(errorMessage, ctx.getValue().name().toLowerCase(Locale.ROOT))
.withSourceSection(createSourceSection(ctx))
.build();
}
result += modifier;
}
// flag modifier combinations that are never valid right away
if (VmModifier.isExternal(result) && !ModuleKeys.isStdLibModule(moduleKey)) {
throw exceptionBuilder()
.evalError("cannotDefineExternalMember")
.withSourceSection(createSourceSection(modifiers, ModifierValue.EXTERNAL))
.build();
}
if (VmModifier.isLocal(result) && VmModifier.isHidden(result)) {
throw exceptionBuilder()
.evalError("redundantHiddenModifier")
.withSourceSection(createSourceSection(modifiers, ModifierValue.HIDDEN))
.build();
}
if (VmModifier.isLocal(result) && VmModifier.isFixed(result)) {
throw exceptionBuilder()
.evalError("redundantFixedModifier")
.withSourceSection(createSourceSection(modifiers, ModifierValue.FIXED))
.build();
}
if (VmModifier.isAbstract(result) && VmModifier.isOpen(result)) {
throw exceptionBuilder()
.evalError("redundantOpenModifier")
.withSourceSection(createSourceSection(modifiers, ModifierValue.OPEN))
.build();
}View on GitHub (pinned to f3efcbfc9b)
Solutions
- Remove the redundant `hidden` modifier, keep `local`.
- If the member should be visible but not rendered in output, drop `local` and keep `hidden`.
Example fix
// before local hidden foo = 1 // after local foo = 1
Defensive patterns
Strategy: validation
Validate before calling
if (/local\s+hidden\b/.test(pklSource)) {
throw new Error("`hidden` is redundant on `local` members; remove one");
} Prevention
- Memorize: `local` already implies invisibility outside the object.
- Lint with a regex or custom `pkl` codegen check in CI.
- Choose between `local` (not visible) and `hidden` (visible but not rendered) — not both.
When it happens
Trigger: Declaring `local hidden foo = ...` in a module, class, or object body.
Common situations: Piling modifiers on for safety without knowing their semantics; adding `hidden` after converting a property to `local`.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- redundantFixedModifier
- moduleMethodMustBeLocal
- invalidObjectMemberModifier
- redundantOpenModifier
- Cannot parse `%s` as number.
AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08).
Data as JSON: /api/errors/83581597ed6b82f0.
Report an issue: GitHub.