tracel-ai/burn · error

`push_combined` should only be called on a ParamGroupMatcher

Error message

`push_combined` should only be called on a ParamGroupMatcher::Combined variant.

What it means

Internal enum-dispatch invariant: `push_combined` on `ParamGroupMatcher` assumes `self` is the `Combined` variant (it is called from `fuse` after matching on `Combined`). The panic fires if the method is invoked on an `All`, `Explicit`, or `Path` matcher — a caller-side misuse of the matcher API that indicates a broken fusion of two parameter-group matchers.

Source

Thrown at crates/burn-core/src/module/param/group.rs:316

            ParamGroupMatcher::Combined(param_group_matchers) => match other.clone() {
                ParamGroupMatcher::All => Self::All,
                ParamGroupMatcher::Explicit(_) => {
                    let mut matchers = (*param_group_matchers).clone();
                    matchers.push(other);
                    Self::Combined(Arc::new(matchers))
                }
                ParamGroupMatcher::Path(_) => {
                    let mut matchers = (*param_group_matchers).clone();
                    matchers.push(other);
                    Self::Combined(Arc::new(matchers))
                }
                ParamGroupMatcher::Combined(other_matchers) => {
                    let mut matchers = (*param_group_matchers).clone();
                    matchers.append(&mut (*other_matchers).clone());
                    Self::Combined(Arc::new(matchers))
                }
            },
            _ => panic!(
                "`push_combined` should only be called on a ParamGroupMatcher::Combined variant."
            ),
        }
    }

    pub(crate) fn fuse(self, other: &Self) -> Self {
        match (self.clone(), other.clone()) {
            (ParamGroupMatcher::All, _) => Self::All,
            (_, ParamGroupMatcher::All) => Self::All,
            (ParamGroupMatcher::Explicit(_), ParamGroupMatcher::Combined(_)) => {
                other.clone().push_combined(self)
            }
            (ParamGroupMatcher::Path(_), ParamGroupMatcher::Combined(_)) => {
                other.clone().push_combined(self)
            }
            (ParamGroupMatcher::Combined(_), ParamGroupMatcher::Explicit(_)) => {
                self.push_combined(other.clone())
            }

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Only call `push_combined` on a matcher known to be `ParamGroupMatcher::Combined` (e.g. match and destructure first).
  2. Use the public `fuse`/merge entry point, which handles all matcher variants, instead of `push_combined` directly.
  3. If a non-Combined matcher must grow, construct a new `Combined` matcher wrapping it plus the new element.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at crates/burn-core/src/module/param/group.rs:316 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05). Data as JSON: /api/errors/78e2e6ded17f1d80. Report an issue: GitHub.