ww imports: require imports before declarations
This commit is contained in:
@@ -249,9 +249,9 @@ main(void)
|
||||
const char *src =
|
||||
"package main;\n"
|
||||
"import zed;\n"
|
||||
"import alpha;\n"
|
||||
"fn f() void = { let s: str = \"import fake;\"; };\n"
|
||||
"/* import hidden; */\n"
|
||||
"import alpha;\n";
|
||||
"/* import hidden; */\n";
|
||||
int errs;
|
||||
const char *pkg;
|
||||
char *got = imports_to_str(src, &errs, &pkg);
|
||||
@@ -266,6 +266,28 @@ main(void)
|
||||
free((void *)pkg);
|
||||
free(got);
|
||||
}
|
||||
{
|
||||
const char *src =
|
||||
"package main;\n"
|
||||
"fn first() void = {};\n"
|
||||
"import alpha;\n"
|
||||
"import beta;\n"
|
||||
"fn second() void = {};\n"
|
||||
"import gamma;\n";
|
||||
int errs;
|
||||
const char *pkg;
|
||||
char *got = imports_to_str(src, &errs, &pkg);
|
||||
if (errs != 2 || got == NULL
|
||||
|| strstr(got, "(use \"alpha\"") == NULL
|
||||
|| strstr(got, "(use \"beta\"") == NULL
|
||||
|| strstr(got, "(use \"gamma\"") == NULL) {
|
||||
fputs("late import sections were not diagnosed and retained\n",
|
||||
stderr);
|
||||
fail++;
|
||||
}
|
||||
free((void *)pkg);
|
||||
free(got);
|
||||
}
|
||||
{
|
||||
int errs;
|
||||
const char *pkg;
|
||||
|
||||
Reference in New Issue
Block a user