Skip to content

allium check: field.unused doesn't count named-argument usage in Entity.created(...) #60

Description

@abalmus-celonis

Version: allium 3.5.0 (language versions: 1, 2, 3).

Bug: allium.field.unused flags an entity field as unused even when it's set via a named argument in an Entity.created(field: value, ...) constructor call in a rule's ensures: clause.

Repro (widget.allium):

-- allium: 3

entity Widget {
    name: String
}

rule MakeWidget {
    when: MakeWidget(name)
    ensures: Widget.created(name: name)
}

Actual:

Field 'Widget.name' is declared but not referenced elsewhere.

Expected: name is set by the Widget.created(name: name) call, so it shouldn't be flagged as unused. Usage tracking for this diagnostic appears to only look for member-access reads (entity.field), not named-argument writes in creation calls — which is the sole way most entity fields ever get populated in a typical spec (per the "Entity creation uses .created() exclusively" convention in the language reference).

Impact: this is the most disruptive of the three related reports (#58, #59) we filed — since .created() with named args is the canonical way to populate a new entity's fields, this diagnostic currently produces a false positive for nearly every field on every entity that's only ever created (not mutated) via a rule.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions