Ruta graveolens  ·  notes from a language experiment  ·  cultivated since 2025

E0491: Duplicate parameter

CodeCategoryStability
E0491Struct and enumPermanent

Explanation

Every named parameter in one function or method parameter list must have a distinct name. Repeating a name would make one argument inaccessible by shadowing its binding, so Rue rejects the declaration rather than choosing one occurrence.

Likely cause

Two parameters were given the same name, often after copying a declaration or when two arguments have the same type. Rename them to express their distinct roles; a method receiver does not conflict with the ordinary parameter-name set.

Examples

Repeat a function parameter name

fn add(value: i32, value: i32) -> i32 { value }
fn main() -> i32 { add(20, 22) }

Give parameters distinct names

fn add(left: i32, right: i32) -> i32 { left + right }
fn main() -> i32 { add(20, 22) }

References