hsutter / cppfront

A personal experimental C++ Syntax 2 -> Syntax 1 compiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

bluetarpmedia opened this issue · 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.