Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V panic when passing undeclared argument to fn #22949

Closed
gechandesu opened this issue Nov 23, 2024 · 0 comments · Fixed by #22950
Closed

V panic when passing undeclared argument to fn #22949

gechandesu opened this issue Nov 23, 2024 · 0 comments · Fixed by #22950
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: Checker Bugs/feature requests, that are related to the type checker.

Comments

@gechandesu
Copy link

gechandesu commented Nov 23, 2024

V doctor:

V full version: V 0.4.8 5ec9bb5.393e4ea
OS: linux, Linux version 6.6.8-arch1-1 (linux@archlinux) (gcc (GCC) 13.2.1 20230801, GNU ld (GNU Binutils) 2.41.0) #1 SMP PREEMPT_DYNAMIC Thu, 21 Dec 2023 19:01:01 +0000
Processor: 16 cpus, 64bit, little endian, 12th Gen Intel(R) Core(TM) i5-1240P

getwd: /home/ge/Code/v/netaddr/issues
vexe: /home/ge/.vlang/v
vexe mtime: 2024-11-23 13:05:19

vroot: OK, value: /home/ge/.vlang
VMODULES: OK, value: /home/ge/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.46.1
Git vroot status: weekly.2024.47-20-g393e4ea8
.git/config present: true

CC version: cc (GCC) 14.2.1 20240910
emcc version: N/A
thirdparty/tcc status: thirdparty-linux-amd64 0134e9b9

What did you do?
./v -g -o vdbg cmd/v && ./vdbg missing_arg_decl.v

module main

// note missing `input` argument in fn signature
fn foo() !string {
	// without next error does not occurs
	a, b := input.split_once('%') or { '', 'empty' }
	if b == '' {
		return error('')
	}
	return a
}

fn main() {
	res := foo('fe80::1234%ne0') or {
		eprintln(err)
		exit(1)
	}
	println(res)
}

What did you expect to see?

V errors undefined ident: input and expected 0 arguments, but got 1

What did you see instead?

================ V panic ================
   module: v.ast
 function: default_table_panic_handler()
  message: 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`.

     file: /home/ge/.vlang/vlib/v/ast/table.v:119
   v hash: 393e4ea
=========================================
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/builtin/builtin.c.v:87: at panic_debug: Backtrace
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/ast/table.v:119: by v__ast__default_table_panic_handler
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/ast/table.v:125: by v__ast__Table_panic
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/ast/table.v:745: by v__ast__Table_sym
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/ast/table.v:778: by v__ast__Table_unalias_num_type
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/checker/check_types.v:403: by v__checker__Checker_check_basic
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/checker/check_types.v:175: by v__checker__Checker_check_types
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/checker/checker.v:1496: by v__checker__Checker_check_or_last_stmt
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/checker/checker.v:1382: by v__checker__Checker_check_or_expr
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/checker/fn.v:748: by v__checker__Checker_call_expr
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/checker/checker.v:2907: by v__checker__Checker_expr
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/checker/assign.v:34: by v__checker__Checker_assign_stmt
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/checker/checker.v:2161: by v__checker__Checker_stmt
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/checker/checker.v:2766: by v__checker__Checker_stmts_ending_with_expression
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/checker/checker.v:2736: by v__checker__Checker_stmts
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/checker/fn.v:517: by v__checker__Checker_fn_decl
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/checker/checker.v:2248: by v__checker__Checker_stmt
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/checker/checker.v:274: by v__checker__Checker_check
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/checker/checker.v:342: by v__checker__Checker_check_files
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/builder/builder.v:131: by v__builder__Builder_middle_stages
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/builder/builder.v:158: by v__builder__Builder_front_and_middle_stages
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/builder/cbuilder/cbuilder.v:71: by v__builder__cbuilder__gen_c
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/builder/cbuilder/cbuilder.v:59: by v__builder__cbuilder__build_c
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/builder/cbuilder/cbuilder.v:49: by v__builder__cbuilder__compile_c
/tmp/v_1000/../../../../../../home/ge/.vlang/vlib/v/builder/rebuilding.v:324: by v__builder__Builder_rebuild

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.

Huly®: V_0.6-21391

@felipensp felipensp self-assigned this Nov 23, 2024
@felipensp felipensp added Bug This tag is applied to issues which reports bugs. Unit: Checker Bugs/feature requests, that are related to the type checker. labels Nov 23, 2024
@felipensp felipensp added the Status: Confirmed This bug has been confirmed to be valid by a contributor. label Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: Checker Bugs/feature requests, that are related to the type checker.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants