Skip to content

V panics on v -check . in module with missing import in file #26458

@gechandesu

Description

@gechandesu

Describe the bug

V panics on running v -check . in the module with multiple files.

Reproduction Steps

Create the foo directory with files:

./
├── connection.v
├── read.v
└── v.mod
// connection.v
module foo

import io

struct Connection {
	buf_size int = 4096
mut:
	stream io.ReaderWriter
}
// read.v
module foo

// Note the missing `import io` and `if err is io.Eof` check in read() fn

// No issue if uncomment this import
// import io

pub fn (mut c Connection) read() !string {
	mut res := []u8{}
	mut nn := 0
	for {
		mut buf := []u8{len: c.buf_size, cap: c.buf_size}
		n := c.stream.read(mut buf) or {
			if err is io.Eof {
				break
			} else {
				return err
			}
		}
		nn += n
		if n == 0 {
			break
		}
		res << buf[..n]
		if res[nn - 1] == `\n` {
			break
		}
	}
	return res#[..-1].bytestr()
}
// v.mod
Module {
	name: 'foo'
	description: ''
	version: '0.0.0'
	license: 'MIT'
	dependencies: []
}

Run in foo/ dir:

v -check .

Expected Behavior

Some normal V error.

Current Behavior

V panic: table.sym: invalid type (typ=ast.Type(0x0 = 0) idx=0). Compiler bug. This should never happen. Please report the bug using `v bug file.v`.

 v hash: 9335a84
    pid: 0x12ce5a
    tid: 0x12ce5a
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:22311: at builtin___v_panic: Backtrace
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:38705: by v__ast__default_table_panic_handler
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:38711: by v__ast__Table_panic
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:39428: by v__ast__Table_sym
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:7233: by v__checker__Checker_infix_expr
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:59830: by v__checker__Checker_expr
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:6667: by v__checker__Checker_if_expr
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:59328: by v__checker__Checker_expr
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:58573: by v__checker__Checker_stmt
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:59260: by v__checker__Checker_stmts_ending_with_expression
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:2997: by v__checker__Checker_call_expr
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:59529: by v__checker__Checker_expr
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:53232: by v__checker__Checker_assign_stmt
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:58615: by v__checker__Checker_stmt
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:59260: by v__checker__Checker_stmts_ending_with_expression
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:59237: by v__checker__Checker_stmts
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:6551: by v__checker__Checker_for_stmt
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:58647: by v__checker__Checker_stmt
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:59260: by v__checker__Checker_stmts_ending_with_expression
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:59237: by v__checker__Checker_stmts
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:2756: by v__checker__Checker_fn_decl
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:58638: by v__checker__Checker_stmt
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:56312: by v__checker__Checker_check
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:56426: by v__checker__Checker_check_files
/tmp/v_1000/v2.01KG0H1W5FN6DDC86HDR5FKA8Z.tmp.c:60936: by v__builder__Builder_middle_stages

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.5.0 9335a84

Environment details (OS name and version, etc.)

V full version V 0.5.0 19e79c4.9335a84
OS linux, Linux version 6.18.6-arch1-1 (linux@archlinux) (gcc (GCC) 15.2.1 20260103, GNU ld (GNU Binutils) 2.45.1) #1 SMP PREEMPT_DYNAMIC Sun, 18 Jan 2026 00:34:07 +0000
Processor 16 cpus, 64bit, little endian, 12th Gen Intel(R) Core(TM) i5-1240P
Memory 4.28GB/15.34GB
V executable /home/ge/.vlang/v
V last modified time 2026-01-27 20:06:54
V home dir OK, value: /home/ge/.vlang
VMODULES OK, value: /home/ge/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /tmp/foo
Git version git version 2.52.0
V git status weekly.2026.03-112-g9335a84e
.git/config present true
cc version cc (GCC) 15.2.1 20260103
gcc version gcc (GCC) 15.2.1 20260103
clang version clang version 21.1.6
tcc version tcc version 0.9.28rc 2025-02-13 HEAD@f8bd136d (x86_64 Linux)
tcc git status thirdparty-linux-amd64 696c1d84
emcc version N/A
glibc version ldd (GNU libc) 2.42

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThis tag is applied to issues which reports bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions