mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
fix
This commit is contained in:
parent
d5e28a827d
commit
0a808f1f26
1 changed files with 24 additions and 25 deletions
|
@ -321,7 +321,6 @@ fn (mut c Checker) comptime_for(mut node ast.ComptimeFor) {
|
|||
} else if node.kind == .values {
|
||||
if sym.kind == .enum {
|
||||
if sym.info is ast.Enum {
|
||||
if sym.info.vals.len > 0 {
|
||||
for _ in sym.info.vals {
|
||||
c.push_new_comptime_info()
|
||||
c.comptime.inside_comptime_for = true
|
||||
|
@ -335,7 +334,6 @@ fn (mut c Checker) comptime_for(mut node ast.ComptimeFor) {
|
|||
c.pop_comptime_info()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
c.error('iterating over .values is supported only for enums, and ${sym.name} is not an enum',
|
||||
node.typ_pos)
|
||||
|
@ -343,7 +341,6 @@ fn (mut c Checker) comptime_for(mut node ast.ComptimeFor) {
|
|||
}
|
||||
} else if node.kind == .methods {
|
||||
methods := sym.get_methods()
|
||||
if methods.len > 0 {
|
||||
for method in methods {
|
||||
c.push_new_comptime_info()
|
||||
c.comptime.inside_comptime_for = true
|
||||
|
@ -357,7 +354,6 @@ fn (mut c Checker) comptime_for(mut node ast.ComptimeFor) {
|
|||
c.stmts(mut node.stmts)
|
||||
c.pop_comptime_info()
|
||||
}
|
||||
}
|
||||
} else if node.kind == .params {
|
||||
if !(sym.kind == .function || sym.name == 'FunctionData') {
|
||||
c.error('iterating over `.params` is supported only for functions, and `${sym.name}` is not a function',
|
||||
|
@ -365,6 +361,9 @@ fn (mut c Checker) comptime_for(mut node ast.ComptimeFor) {
|
|||
return
|
||||
}
|
||||
method := c.comptime.comptime_for_method
|
||||
// example: fn (mut d MyStruct) add(x int, y int) string
|
||||
// `d` is params[0], `x` is params[1], `y` is params[2]
|
||||
// so we at least has one param (`d`) for method
|
||||
for param in method.params[1..] {
|
||||
c.push_new_comptime_info()
|
||||
c.comptime.inside_comptime_for = true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue