Skip to content

[BUG] cppfront confused by function expression in for's (next) expression #432

Closed
@JohelEGP

Description

@JohelEGP

Title: Confused by function expression in for's (next) expression.

Description:

It seems something enters a bad state.
Unparenthesized, it complains about a missing do.
Parenthesized, lifetime analysis says the loop variable is uninitialized.

Minimal reproducer (https://cpp2.godbolt.org/z/Er81zc91E, https://cpp2.godbolt.org/z/a75sW77bs):

main: (args) = {
  for args next :() = 0 do (arg) std::cout << arg;
}
main: (args) = {
  for args next (:() = 0) do (arg) std::cout << arg;
}

Commands:

cppfront -clean-cpp1 main.cpp2

Actual result and error:

main.cpp2(2,25): error: 'for range' must be followed by 'do ( parameter )' (at 'do')
main.cpp2(2,49): error: local variable arg is used before it was initialized
  ==> program violates initialization safety guarantee - see previous errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions