bugfix: v should not panic when encountering a file that consists only of comments
parent
e56bf42270
commit
88b402fcf8
|
@ -828,7 +828,7 @@ pub fn (v mut V) parse_lib_imports() {
|
|||
pidx := v.parse(file, .imports)
|
||||
p_mod := v.parsers[pidx].mod
|
||||
if p_mod != mod {
|
||||
v.parsers[pidx].error_with_token_index('bad module definition: ${v.parsers[pidx].file_path} imports module "$mod" but $file is defined as module `$p_mod`', 1)
|
||||
v.parsers[pidx].error_with_token_index('bad module definition: ${v.parsers[pidx].file_path} imports module "$mod" but $file is defined as module `$p_mod`', 0)
|
||||
}
|
||||
}
|
||||
done_imports << mod
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
/*
|
||||
module acommentedmodule
|
||||
|
||||
|
||||
*/
|
|
@ -0,0 +1,3 @@
|
|||
import compiler.tests.modules.acommentedmodule
|
||||
===output===
|
||||
vlib/compiler/tests/modules/acommentedmodule/commentedfile.v:7:1: bad module definition: vlib/compiler/tests/modules/acommentedmodule/commentedfile.v imports module "compiler.tests.modules.acommentedmodule" but vlib/compiler/tests/modules/acommentedmodule/commentedfile.v is defined as module `main`
|
|
@ -51,6 +51,7 @@ fn diff_files( file_result, file_expected string ) string {
|
|||
}
|
||||
|
||||
pub fn run_repl_file(wd string, vexec string, file string) ?string {
|
||||
vexec_folder := filepath.dir(vexec) + filepath.separator
|
||||
fcontent := os.read_file(file) or { return error('Could not read file ${file}') }
|
||||
content := fcontent.replace('\r', '')
|
||||
input := content.all_before('===output===\n')
|
||||
|
@ -74,6 +75,8 @@ pub fn run_repl_file(wd string, vexec string, file string) ?string {
|
|||
.replace('... ', '')
|
||||
.all_after('Use Ctrl-C or `exit` to exit\n')
|
||||
.replace(wd + filepath.separator, '' )
|
||||
.replace(vexec_folder, '')
|
||||
.replace('\\', '/')
|
||||
|
||||
if result != output {
|
||||
file_result := '${file}.result.txt'
|
||||
|
|
Loading…
Reference in New Issue