hsutter / cppfront

A personal experimental C++ Syntax 2 -> Syntax 1 compiler
Other
5.47k stars 242 forks source link

[BUG] using the using keyword inside a namespace with global functions results in code that does not compile #1213

Open farmerpiki opened 2 months ago

farmerpiki commented 2 months ago

quick example for reproducing:

xf: () -> int = 42;
qq: namespace = {
using ::xf;
}

results in:

namespace qq {
using ::xf;
}

being declared before [[nodiscard]] auto xf() -> int; which makes the code not compile due to cpp1 requiring ordering.

JohelEGP commented 1 week ago

See also #470 and https://github.com/hsutter/cppfront/discussions/641#discussioncomment-6869498.

farmerpiki commented 1 week ago

Of a Cpp2 function, its Cpp1 declaration. Of a Cpp2 non-expression alias, its Cpp1 declaration. Of a Cpp2 expression alias, its Cpp1 definition.

JohelEGP commented 1 week ago

Yeah, it doesn't mention namespaces. I suppose they're implicit, since they're required anyways. The comment is from months before using declarations (commit dd047033de5a691721069eb9ddb5b4f7892afa94).