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 error in generic function printing interpolation invalid field #23511

Closed
jorgeluismireles opened this issue Jan 18, 2025 · 1 comment · Fixed by #23515
Closed

Compiler error in generic function printing interpolation invalid field #23511

jorgeluismireles opened this issue Jan 18, 2025 · 1 comment · Fixed by #23515
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Unit: Checker Bugs/feature requests, that are related to the type checker.

Comments

@jorgeluismireles
Copy link

jorgeluismireles commented Jan 18, 2025

Describe the bug

Compiler error in generic function printing interpolation invalid field.

Reproduction Steps

Three debugs to print a typo error field. debug_1 and debug_2 gives correct V errors. debug_3 gives Compiler error:

struct User { }

fn (u &User) debug_1() {
	println('${u.typo}')
}
fn debug_2[T](t T) {
	_ := t.typo
}
fn debug_3[T](t T) {
	println('${t.typo}')
}

fn main() {
	u := &User{}
	//u.debug_1() // V error ok: type `User` has no field named `typo`
	//debug_2(u) // V error ok: type `User` has no field named `typo`
	debug_3(u) // C error
}

Expected Behavior

debug_3 should give V error as debug_2 does.

Current Behavior

Running code...
Can't run code. The server returned an error:
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: c2b7dbf
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:19214: at _v_panic: Backtrace
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:36415: by v__ast__default_table_panic_handler
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:36421: by v__ast__Table_panic
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:37134: by v__ast__Table_sym
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:4016: by v__checker__Checker_markused_string_inter_lit
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:2498: by v__checker__Checker_string_inter_lit
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:52947: by v__checker__Checker_expr
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:59930: by v__checker__Checker_builtin_args
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:60687: by v__checker__Checker_fn_call
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:59864: by v__checker__Checker_call_expr
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:52331: by v__checker__Checker_expr
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:51511: by v__checker__Checker_stmt
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:52094: by v__checker__Checker_stmts_ending_with_expression
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:52071: by v__checker__Checker_stmts
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:59660: by v__checker__Checker_fn_decl
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:62075: by v__checker__Checker_post_process_generic_fns
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:49582: by v__checker__Checker_check_files
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:48093: by v__builder__Builder_middle_stages
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:48131: by v__builder__Builder_front_and_middle_stages
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:50624: by v__builder__cbuilder__gen_c
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:50596: by v__builder__cbuilder__build_c
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:50587: by v__builder__cbuilder__compile_c
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:50508: by v__builder__Builder_rebuild
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:49661: by v__builder__compile
/tmp/v_1000/v.01JHXHEYHBRBCF1FZNXNWKYSB3.tmp.c:51017: by main__rebuild
Exited with error status 1
Please try again.

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.9 c2b7dbf

Environment details (OS name and version, etc.)

https://play.vlang.io/p/6a9c0a5f77

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.

@jorgeluismireles jorgeluismireles added the Bug This tag is applied to issues which reports bugs. label Jan 18, 2025
Copy link

Connected to Huly®: V_0.6-21940

@felipensp felipensp self-assigned this Jan 19, 2025
@felipensp felipensp added the Unit: Checker Bugs/feature requests, that are related to the type checker. label Jan 19, 2025
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. 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