diff --git a/vlib/v/checker/tests/module_multiple_names_err.out b/vlib/v/checker/tests/module_multiple_names_err.out deleted file mode 100644 index 5c195ef290..0000000000 --- a/vlib/v/checker/tests/module_multiple_names_err.out +++ /dev/null @@ -1,5 +0,0 @@ -vlib/v/checker/tests/module_multiple_names_err.vv:1:13: error: `module x` can only declare one module - 1 | module main os - | ~~ - 2 | fn main() { - 3 | println('hello, world') diff --git a/vlib/v/checker/tests/module_syntax_err.out b/vlib/v/checker/tests/module_syntax_err.out deleted file mode 100644 index 4f3dcb4d11..0000000000 --- a/vlib/v/checker/tests/module_syntax_err.out +++ /dev/null @@ -1,5 +0,0 @@ -vlib/v/checker/tests/module_syntax_err.vv:1:12: error: `module x` syntax error - 1 | module main.os - | ^ - 2 | fn main() { - 3 | println('hello, world') diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 01773c9c5c..5e20e5ac7d 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -1835,12 +1835,14 @@ fn (mut p Parser) module_decl() ast.Module { // as it creates a wrong position when extended // to module_pos n_pos := p.tok.position() - if module_pos.line_nr == n_pos.line_nr && p.tok.kind != .comment { - if p.tok.kind != .name { - p.error_with_pos('`module x` syntax error', n_pos) + if module_pos.line_nr == n_pos.line_nr && p.tok.kind != .comment && p.tok.kind != .eof { + if p.tok.kind == .name { + p.error_with_pos('`module $name`, you can only declare one module, unexpected `$p.tok.lit`', + n_pos) return mod_node } else { - p.error_with_pos('`module x` can only declare one module', n_pos) + p.error_with_pos('`module $name`, unexpected `$p.tok.kind` after module name', + n_pos) return mod_node } } diff --git a/vlib/v/parser/tests/module_multiple_names_err.out b/vlib/v/parser/tests/module_multiple_names_err.out new file mode 100644 index 0000000000..6ae53a8732 --- /dev/null +++ b/vlib/v/parser/tests/module_multiple_names_err.out @@ -0,0 +1,5 @@ +vlib/v/parser/tests/module_multiple_names_err.vv:1:13: error: `module main`, you can only declare one module, unexpected `os` + 1 | module main os + | ~~ + 2 | fn main() { + 3 | println('hello, world') diff --git a/vlib/v/checker/tests/module_multiple_names_err.vv b/vlib/v/parser/tests/module_multiple_names_err.vv similarity index 100% rename from vlib/v/checker/tests/module_multiple_names_err.vv rename to vlib/v/parser/tests/module_multiple_names_err.vv diff --git a/vlib/v/parser/tests/module_syntax_err.out b/vlib/v/parser/tests/module_syntax_err.out new file mode 100644 index 0000000000..38a1905e18 --- /dev/null +++ b/vlib/v/parser/tests/module_syntax_err.out @@ -0,0 +1,5 @@ +vlib/v/parser/tests/module_syntax_err.vv:1:12: error: `module main`, unexpected `.` after module name + 1 | module main.os + | ^ + 2 | fn main() { + 3 | println('hello, world') diff --git a/vlib/v/checker/tests/module_syntax_err.vv b/vlib/v/parser/tests/module_syntax_err.vv similarity index 100% rename from vlib/v/checker/tests/module_syntax_err.vv rename to vlib/v/parser/tests/module_syntax_err.vv