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

checker: disallow iterating through .params if not a function #22428

Merged
merged 5 commits into from
Oct 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions vlib/v/checker/comptime.v
Original file line number Diff line number Diff line change
Expand Up @@ -326,16 +326,16 @@ fn (mut c Checker) comptime_for(mut node ast.ComptimeFor) {
c.pop_comptime_info()
}
} else if node.kind == .params {
if sym.kind == .function {
if !(sym.kind == .function || sym.name == 'FunctionData') {
c.error('iterating over `.params` is supported only for functions, and `${sym.name}` is not a function',
node.typ_pos)
return
} else {
Delta456 marked this conversation as resolved.
Show resolved Hide resolved
c.push_new_comptime_info()
c.comptime.inside_comptime_for = true
c.comptime.comptime_for_method_param_var = node.val_var
c.stmts(mut node.stmts)
c.pop_comptime_info()
} else {
c.error('iterating over `.params` is supported only for functions, and `${sym.name}` is not a function',
node.typ_pos)
return
}
} else if node.kind == .variants {
if c.variant_data_type == 0 {
Expand Down
Loading