diff --git a/releasenotes.md b/releasenotes.md index a46fc33d1..5a51d9e67 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -39,6 +39,7 @@ - `i` suffixes were not caught when n < 8, causing an assert. - Parse error in `$defined` was not handled correctly, leading to an assertion. - Assert when struct size would exceed 4 GB. +- Assert when encountering a malformed module alias. ### Stdlib changes - Add `ThreadPool` join function to wait for all threads to finish in the pool without destroying the threads. diff --git a/src/compiler/parse_global.c b/src/compiler/parse_global.c index 9b6635178..9c9b0c611 100644 --- a/src/compiler/parse_global.c +++ b/src/compiler/parse_global.c @@ -2471,6 +2471,12 @@ static inline Decl *parse_alias_module(ParseContext *c, Decl *decl, TokenType to decl->decl_kind = DECL_ALIAS_PATH; + if (!tok_is(c, TOKEN_IDENT)) + { + PRINT_ERROR_HERE("'module' should be followed by a module name."); + return poisoned_decl; + } + Path *path = parse_module_path(c); if (!path) return poisoned_decl; diff --git a/test/src/test_suite_runner.c3 b/test/src/test_suite_runner.c3 index a30ddbf5e..850e4771a 100644 --- a/test/src/test_suite_runner.c3 +++ b/test/src/test_suite_runner.c3 @@ -598,7 +598,7 @@ fn bool test_file(Path file_path, TestOutput* output, usz index) } if (try next) { - io::fprintfn((OutStream)&output.buffer, `FAILED - %s did not contain: "%s"`, file.ptr.name, next)!!; + io::fprintfn((OutStream)&output.buffer, `FAILED - %s did not contain: %s`, file.ptr.name, next)!!; io::fprintfn((OutStream)&output.buffer, "\n\n\n---------------------------------------------------> %s\n\n", file.ptr.name)!!; (void)file_ll.seek(0); io::fprintn((OutStream)&output.buffer, (String)io::read_fully(tmem, &file_ll))!!; diff --git a/test/test_suite/module/module_alias_broken.c3 b/test/test_suite/module/module_alias_broken.c3 new file mode 100644 index 000000000..e25a19460 --- /dev/null +++ b/test/test_suite/module/module_alias_broken.c3 @@ -0,0 +1 @@ +alias foo = module; // #error: 'module' should be followed by a module name. \ No newline at end of file diff --git a/test/test_suite/struct/struct_too_large.c3 b/test/test_suite/struct/struct_too_large.c3 index 7b80726e1..81a7c8d76 100644 --- a/test/test_suite/struct/struct_too_large.c3 +++ b/test/test_suite/struct/struct_too_large.c3 @@ -2,7 +2,7 @@ import std; struct Foo { int a; - int[int.max] b; // #error: "Struct member 'b' would cause the struct to become too large + int[int.max] b; // #error: Struct member 'b' would cause the struct to become too large } fn int main()