Skip to content

refactor: dead AttributeName::Lazy arms — narrow ValidatedAttribute::name() #1488

Description

@shunichironomura

Warning

This content was written by an AI agent and must be verified by a human developer. After human verification, this alert may be removed.

Summary

validate_attributes returns UnsupportedLazy before it ever constructs a ValidatedAttribute, so a ValidatedAttribute can never report name() == AttributeName::Lazy. Both consumers nevertheless still match on that variant, and so does the producing module itself.

Dead sites

  • crates/graphcal-compiler/src/ir/resolve/mod.rs:730-734 — AttributeName::Lazy => return Err(LazyNotSupported)
  • crates/graphcal-eval/src/project_compiler/imports.rs:347-352 — same
  • crates/graphcal-compiler/src/ir/resolve/attribute_validation.rs:135 — AttributeName::Hidden | AttributeName::Lazy => Vec::new() mentions a variant this arm can never take

Why it is unreachable

crates/graphcal-compiler/src/ir/resolve/attribute_validation.rs:112-116, inside the per-attribute closure and ahead of every ValidatedAttribute construction:

if matches!(name, AttributeName::Lazy) {
    return Err(AttributeValidationError::UnsupportedLazy {
        span: attribute.span,
    });
}

Impact

Dead code, plus a missed opportunity to encode the invariant. Per AGENTS.md:

The compiler is the language's first user — its own implementation must hold itself to the same explicitness standard the language enforces on graphcal programs.

The invariant "a validated attribute is never Lazy" is currently enforced by an early return that nothing downstream can see, rather than by a type.

Suggested fix

Have ValidatedAttribute::name() return a narrower SupportedAttributeName covering only the three variants that can survive validation. The compiler then deletes the dead arms for you and makes the invariant unforgettable for future consumers.

Worth doing before the related attribute-validation cleanups, because it turns those arm deletions into compile errors rather than judgement calls.

Provenance

Found during a full-workspace code review at 6e462341a (v0.0.1-alpha.27). Baseline at that commit: cargo clippy --workspace --all-targets clean, cargo test --workspace 2926 passed / 0 failed, cargo deny check advisories ok.

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

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions