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

Compiler panic when calling map.keys() or map.values() in a generic function #20058

Closed
lv37 opened this issue Dec 1, 2023 · 0 comments · Fixed by #20059
Closed

Compiler panic when calling map.keys() or map.values() in a generic function #20058

lv37 opened this issue Dec 1, 2023 · 0 comments · Fixed by #20059
Assignees
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@lv37
Copy link
Contributor

lv37 commented Dec 1, 2023

Describe the bug

Trying to compile

module main

fn generic[T](a T) {
	a.keys() // same error with a.values()
}

fn main() {
	a := { 'aa': 11 }
	generic(a)
}

gives

V panic: as cast: cannot cast `unknown` to `v.ast.Map`

Reproduction Steps

Try compiling the above code

Expected Behavior

Compile successfully

Current Behavior

V panic: as cast: cannot cast `unknown` to `v.ast.Map`
v hash: be51143
/tmp/v_1002/v2.5487961839979887618.tmp.c:21153: at _v_panic: Backtrace
/tmp/v_1002/v2.5487961839979887618.tmp.c:21638: by __as_cast
/tmp/v_1002/v2.5487961839979887618.tmp.c:30537: by v__checker__Checker_map_builtin_method_call
/tmp/v_1002/v2.5487961839979887618.tmp.c:29595: by v__checker__Checker_method_call
/tmp/v_1002/v2.5487961839979887618.tmp.c:28427: by v__checker__Checker_call_expr
/tmp/v_1002/v2.5487961839979887618.tmp.c:21637: by v__checker__Checker_expr
/tmp/v_1002/v2.5487961839979887618.tmp.c:20906: by v__checker__Checker_stmt
/tmp/v_1002/v2.5487961839979887618.tmp.c:21426: by v__checker__Checker_stmts_ending_with_expression
/tmp/v_1002/v2.5487961839979887618.tmp.c:21402: by v__checker__Checker_stmts
/tmp/v_1002/v2.5487961839979887618.tmp.c:28262: by v__checker__Checker_fn_decl
/tmp/v_1002/v2.5487961839979887618.tmp.c:30346: by v__checker__Checker_post_process_generic_fns
/tmp/v_1002/v2.5487961839979887618.tmp.c:19163: by v__checker__Checker_check_files
/tmp/v_1002/v2.5487961839979887618.tmp.c:47889: by v__builder__Builder_middle_stages
/tmp/v_1002/v2.5487961839979887618.tmp.c:47923: by v__builder__Builder_front_and_middle_stages
/tmp/v_1002/v2.5487961839979887618.tmp.c:50370: by v__builder__cbuilder__gen_c
/tmp/v_1002/v2.5487961839979887618.tmp.c:50353: by v__builder__cbuilder__build_c
/tmp/v_1002/v2.5487961839979887618.tmp.c:50343: by v__builder__cbuilder__compile_c
/tmp/v_1002/v2.5487961839979887618.tmp.c:50249: by v__builder__Builder_rebuild
/tmp/v_1002/v2.5487961839979887618.tmp.c:49354: by v__builder__compile
/tmp/v_1002/v2.5487961839979887618.tmp.c:50684: by main__rebuild
/tmp/v_1002/v2.5487961839979887618.tmp.c:50573: by main__main
/tmp/v_1002/v2.5487961839979887618.tmp.c:51349: by main

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.3 be51143

Environment details (OS name and version, etc.)

V full version: V 0.4.3 b347f54.be51143
OS: linux, Linux version 6.5.12-300.fc39.x86_64 (mockbuild@cda4963b6857459f9d1b40ea59f8a44a) (gcc (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4), GNU ld version 2.40-13.fc39) #1 SMP PREEMPT_DYNAMIC Mon Nov 20 22:44:24 UTC 2023
Processor: 4 cpus, 64bit, little endian, Intel(R) Core(TM) i5-4310U CPU @ 2.00GHz

getwd: /home/user/Projects/v-testing/webview/utils
vexe: /home/user/.local/lib/v/v
vexe mtime: 2023-12-01 18:36:54

vroot: OK, value: /home/user/.local/lib/v
VMODULES: OK, value: /home/user/.vmodules
VTMP: OK, value: /tmp/v_1002

Git version: git version 2.43.0
Git vroot status: weekly.2023.48-28-gbe51143a
.git/config present: true

CC version: cc (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4)
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3

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.

@lv37 lv37 added the Bug This tag is applied to issues which reports bugs. label Dec 1, 2023
@Delta456 Delta456 self-assigned this Dec 1, 2023
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants