Skip to content

v: implement comptime regular func params traversing#25322

Merged
spytheman merged 1 commit into
vlang:masterfrom
felipensp:feature_comptime_params_on_regular_funcs
Sep 16, 2025
Merged

v: implement comptime regular func params traversing#25322
spytheman merged 1 commit into
vlang:masterfrom
felipensp:feature_comptime_params_on_regular_funcs

Conversation

@felipensp

@felipensp felipensp commented Sep 16, 2025

Copy link
Copy Markdown
Member
fn demo(a int, b string) {
}

fn g [T](cb T) {
	mut params := []FunctionParam{}
     $if T is $function {
        $for param in T.params {
			params << param
        }
    }
	assert params.len == 2
	assert params[0].name == 'a'
	assert params[0].typ == 8
	assert params[1].name == 'b'
	assert params[1].typ == 21
}

fn main() {
    g(demo)

	mut params := []FunctionParam{}
	$for param in demo.params {
		params << param
	}
	assert params.len == 2
	assert params[0].name == 'a'
	assert params[0].typ == 8
	assert params[1].name == 'b'
	assert params[1].typ == 21
}

@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-25633

@felipensp felipensp marked this pull request as ready for review September 16, 2025 11:17
@felipensp felipensp added the Feature/Enhancement Request This issue is made to request a feature or an enhancement to an existing one. label Sep 16, 2025

@spytheman spytheman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Excellent work.

Comment thread vlib/builtin/builtin.v
@spytheman spytheman merged commit 97edd61 into vlang:master Sep 16, 2025
83 checks passed
@felipensp felipensp deleted the feature_comptime_params_on_regular_funcs branch September 17, 2025 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature/Enhancement Request This issue is made to request a feature or an enhancement to an existing one.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants