Improve error message when using ',' in struct declarations. #1920

This commit is contained in:
Christoffer Lerno
2025-02-02 22:44:22 +01:00
parent 50c590bb5f
commit f2df4855ff
3 changed files with 12 additions and 0 deletions

View File

@@ -14,6 +14,7 @@
- Experimental change from `[*]` to `[?]`
- Warn on if-catch with just a `default` case.
- Compile time array inc/dec.
- Improve error message when using ',' in struct declarations. #1920
### Fixes
- Fix issue requiring prefix on a generic interface declaration.

View File

@@ -1629,6 +1629,10 @@ static bool parse_struct_body(ParseContext *c, Decl *parent)
{
RETURN_PRINT_ERROR_AT(false, member, "'inline' can only be applied to a single member, so please define it on its own line.");
}
if (token_is_any_type(c->tok))
{
RETURN_PRINT_ERROR_LAST("Did you accidentally use ',' rather than ';' between your declarations?");
}
}
Decl **members = parent->strukt.members;
unsigned last_index = vec_size(members) - 1;

View File

@@ -0,0 +1,7 @@
import std::io;
struct Test
{
int a, // #error: Did you accidentally use ','
int b,
}