cppfront icon indicating copy to clipboard operation
cppfront copied to clipboard

[BUG] Allow `static_assert` at file scope when cppfront runs in Pure Cpp2 mode

Open bluetarpmedia opened this issue 9 months ago • 2 comments

(This might be more of a suggestion than a bug.)

Describe the bug Cannot use static_assert at file scope when cppfront runs in Pure Cpp2 mode.

To Reproduce Run cppfront on this code:

verify: (func, arg) -> bool == {
    return func(arg);
}

static_assert( verify(:(i: int) i < 10, 5) );  // Does not compile

main: () -> int = {

    static_assert( verify(:(i: int) i < 10, 5) );  // OK
    
    return 0;
}

The static_assert line at file scope does not compile because cppfront interprets it as C++ rather than Cpp2. But when cppfront runs in pure mode, the static_assert could be interpreted as being a Cpp2 statement.

bluetarpmedia avatar May 21 '24 02:05 bluetarpmedia