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

cgen, checker: fix comptime map type resolution on generic arg #20097

Merged
merged 4 commits into from
Dec 7, 2023

Conversation

felipensp
Copy link
Member

@felipensp felipensp commented Dec 5, 2023

Fix #20089

🤖[deprecated] Generated by Copilot at 531969f

This pull request adds support for comptime map arguments in generic functions. It modifies the vlib/v/checker/fn.v and vlib/v/gen/c/fn.v files to handle map types in the checker and gen modules.

🤖[deprecated] Generated by Copilot at 531969f

  • Add support for passing maps as comptime arguments to generic functions (link, link)

@felipensp felipensp marked this pull request as ready for review December 6, 2023 16:23
@@ -4631,7 +4631,7 @@ fn (mut g Gen) cast_expr(node ast.CastExpr) {
&& (sym.info as ast.Alias).parent_type !in [expr_type, ast.string_type]) {
if sym.kind == .string && !node.typ.is_ptr() {
cast_label = '*(string*)&'
} else {
} else if !(g.is_cc_msvc && g.typ(node.typ) == g.typ(expr_type)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is unfortunate, that this msvc specific thing is needed :-| .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have a good alternative though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is unfortunate, that this msvc specific thing is needed :-| .

Yes, so bad.

Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.

@spytheman spytheman merged commit c121f56 into vlang:master Dec 7, 2023
54 checks passed
@felipensp felipensp deleted the fix_map_generic_arg branch December 7, 2023 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong cast when passing a map to a generic function
2 participants