1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

v: support $for attr in Test.attributes (#9836)

This commit is contained in:
Louis Schmieder
2021-04-25 17:29:26 +02:00
committed by GitHub
parent 515e83dcbc
commit fc3b628440
6 changed files with 55 additions and 1 deletions

View File

@@ -253,8 +253,15 @@ fn (mut p Parser) comp_for() ast.CompFor {
pos: var_pos
})
kind = .fields
} else if for_val == 'attributes' {
p.scope.register(ast.Var{
name: val_var
typ: p.table.find_type_idx('StructAttribute')
pos: var_pos
})
kind = .attributes
} else {
p.error_with_pos('unknown kind `$for_val`, available are: `methods` or `fields`',
p.error_with_pos('unknown kind `$for_val`, available are: `methods`, `fields` or `attributes`',
p.prev_tok.position())
return ast.CompFor{}
}