Skip to content

Enumerator @param tags are never validated against the enumerator's fields #820

Description

@pepone

@param tags are permitted on enumerators (only_operations_have_parameters in slicec/src/validators/comments.rs allows Entities::Enumerator), but unlike operation parameters (validate_param_tags in slicec/src/validators/operations.rs) the tag's identifier is never checked against the enumerator's fields, and nothing rejects the tag on an enumerator that has no fields. All three of these compile without a single lint:

module tests

enum E {
    /// @param nmae: typo, no field is called 'nmae'
    A(name: string)

    /// @param x: this enumerator has no fields
    B
}

enum Status : int32 {
    /// @param code: enumerators of a basic enum can never have fields
    Ok = 0
}

With #818, a variant field only receives a comment when a @param tag names it, so the typo above silently produces an undocumented field in the generated code; the other two tags are silently discarded.

Suggested fix: validate enumerator @param identifiers against enumerator.fields() the same way validate_param_tags does for operations. That also rejects @param on fieldless and basic-enum enumerators.


Found while reviewing #818 (Claude Fable 5.1, cross-checked with Codex; the silent acceptance was confirmed by compiling the snippet above and observing zero diagnostics). Not yet human-triaged.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    slicecRelated to the 'slicec' crate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions