Skip to content

[BUG] Parse error with template type and initialiser without white space in between #1162

Closed
@bluetarpmedia

Description

@bluetarpmedia

Describe the bug
Cppfront reports an error when parsing the following expression, presumably because of the ambiguity of >=.

vec: std::vector<int>=(1,2,3);

To Reproduce
Run cppfront on this code:

main: () -> int = {
    v1: std::vector<int> = (1,2,3);  // OK
    v2: std::vector<int> =(1,2,3);   // OK
    v3: std::vector<int>=(1,2,3);    // Error
    v4: std::vector<int>= (1,2,3);   // Error
    return 0;
}

The error is:

error: missing ';' at end of declaration or '=' at start of initializer (at '<')
error: ill-formed initializer (at '{')
error: unexpected text at end of Cpp2 code section (at 'main')
error: parse failed for section starting here

Repro on Godbolt

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