apple/pkl · error

redundantFixedModifier

redundantFixedModifier

Error message

redundantFixedModifier

What it means

`local` members cannot be referenced from outside their defining object, so `fixed` (which prevents amendment) adds nothing. AstBuilder rejects `local fixed` with `redundantFixedModifier`, pointing at the FIXED modifier (AstBuilder.java:3023).

Source

Thrown at pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java:3023

    // 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();
    }

    return result;
  }

  private UnresolvedTypeNode[] doVisitParameterTypes(ObjectBody body) {
    return doVisitParameterTypes(body.getParameters());
  }

View on GitHub (pinned to f3efcbfc9b)

Solutions

  1. Remove the redundant `fixed` modifier and keep `local`.
  2. If you truly need amending-protection with visibility, drop `local` and keep `fixed`.

Example fix

// before
local fixed foo = 1
// after
local foo = 1
Defensive patterns

Strategy: validation

Validate before calling

if (/local\s+fixed\b/.test(pklSource)) {
  throw new Error("`fixed` is redundant on `local` members; remove one");
}

Prevention

When it happens

Trigger: Declaring `local fixed foo = ...` in any module, class, or object body.

Common situations: Defensive modifier stacking; converting a `fixed` property to `local` without removing `fixed`.

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


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