Skip to content

Fix translations for unnamed function parameters#197

Merged
nunoplopes merged 2 commits into
Cpp2Rust:masterfrom
joaotgouveia:unnamed-function-parameters
Jun 20, 2026
Merged

Fix translations for unnamed function parameters#197
nunoplopes merged 2 commits into
Cpp2Rust:masterfrom
joaotgouveia:unnamed-function-parameters

Conversation

@joaotgouveia

Copy link
Copy Markdown
Contributor

The current implementation of GetNamedDeclAsString defaults to returning self whenever the declaration corresponds to an unnamed function parameter. This leads to incorrect translations such as the following:

int main(int, char**) { return 0; }
fn main_0(self: i32, self: Ptr<Ptr<u8>>) -> i32 {
    let self: Value<i32> = Rc::new(RefCell::new(self));
    let self: Value<Ptr<Ptr<u8>>> = Rc::new(RefCell::new(self));
    return 0;
}

This patch addresses this issue by changing GetNamedDeclAsString to return self only when it is actually required, and _ otherwise.

@joaotgouveia joaotgouveia force-pushed the unnamed-function-parameters branch from d540109 to cd32680 Compare June 20, 2026 01:41
@nunoplopes nunoplopes merged commit 0dfb5ba into Cpp2Rust:master Jun 20, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants