Skip to content

Rust: complexity and bool_ops skip && inside let chains #26

Closed

Description

@ElbertePlinio

Found in review of the #7 cognitive spec.

In tree-sitter-rust 0.24.2 the condition of if_expression, while_expression, and a match_pattern guard can be a let_chain node whose && tokens are anonymous children, not binary_expression nodes. rust_decision and is_boolean_operator only look at binary_expression, so those operators count for neither metric.

fn f(x: Option<u8>, y: Option<u8>, c: bool) {
    if let Some(a) = x && let Some(b) = y && c && a > b {}
}

pickcheck 0.3.0 reports complexity 2 and bool_ops 0; the spec gives 5 and 3. The repo itself uses let chains (edition 2024), so this undercounts its own gate.

Fix: count each anonymous && child of let_chain as a decision point and as a boolean operator in the chain. Needs a Rust golden fixture with a let chain.

Activity

  1. added
    bug
    on Sep 27, 2026
  2. added a commit that references this issue on Sep 28, 2026
    469116c
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions