diff --git a/releasenotes.md b/releasenotes.md index 9dda9ae88..0f630fce5 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -6,6 +6,7 @@ - Const vector -> const slice implicit conversion. - Slicing arrays, slices and bytes at compile time #1466. - Better error for `int a[4] = ...`. #1518 +- Better error for `int Foo(int a)` declarations #1516 ### Fixes - `Unsupported int[*] $x = { 1, 2, 3, 4 }` #1489. diff --git a/src/compiler/parse_global.c b/src/compiler/parse_global.c index 593e45e71..0f568fbd7 100644 --- a/src/compiler/parse_global.c +++ b/src/compiler/parse_global.c @@ -1134,6 +1134,14 @@ static inline Decl *parse_global_declaration(ParseContext *c) { if (token_is_some_ident(c->tok)) { + if ((c->tok == TOKEN_TYPE_IDENT || c->tok == TOKEN_CONST_IDENT) && + c->lexer.token_type == TOKEN_LPAREN) + { + PRINT_ERROR_HERE("This looks like the beginning of a C style function declaration. " + "Unfortunately it seems to be missing the initial 'fn' and " + "the function name does not start with a lower case."); + return poisoned_decl; + } PRINT_ERROR_HERE("I expected a variable name here, but global variables need to start with lower case."); return poisoned_decl; } diff --git a/test/unit/stdlib/crypto/rc4.c3 b/test/unit/stdlib/crypto/rc4.c3 index 29a482ee5..cf7fcec8f 100644 --- a/test/unit/stdlib/crypto/rc4.c3 +++ b/test/unit/stdlib/crypto/rc4.c3 @@ -8,9 +8,9 @@ fn void! rc_crypt() @test char[200] x; String text = "The quick brown fox jumps over the lazy dog."; rc.crypt(text, &x); - char[*] res = x`2ac2fecdd8fbb84638e3a4 + char[*] res = x'2ac2fecdd8fbb84638e3a4 820eb205cc8e29c28b9d5d 6b2ef974f311964971c90e - 8b9ca16467ef2dc6fc3520`; + 8b9ca16467ef2dc6fc3520'; assert(res[:text.len] == x[:text.len]); } \ No newline at end of file