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

checker: add a notice about skipping the generic route methods of vweb apps (#16013)

This commit is contained in:
yuyi 2022-10-10 07:50:10 +08:00 committed by GitHub
parent 553315b80c
commit 32ab08287c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,18 @@ fn (mut c Checker) fn_decl(mut node ast.FnDecl) {
eprintln('>>> post processing node.name: ${node.name:-30} | $node.generic_names <=> $c.table.cur_concrete_types')
}
}
// notice vweb route methods (non-generic method)
if node.generic_names.len > 0 {
typ_vweb_result := c.table.find_type_idx('vweb.Result')
if node.return_type == typ_vweb_result {
rec_sym := c.table.sym(node.receiver.typ)
if rec_sym.kind == .struct_ {
if _ := c.table.find_field_with_embeds(rec_sym, 'Context') {
c.note('generic method routes of vweb will be skipped', node.pos)
}
}
}
}
if node.generic_names.len > 0 && c.table.cur_concrete_types.len == 0 {
// Just remember the generic function for now.
// It will be processed later in c.post_process_generic_fns,