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

cgen: fix vweb app route methods filtering (#16186)

This commit is contained in:
yuyi 2022-10-24 17:51:20 +08:00 committed by GitHub
parent 26c737b6db
commit 4aa4af4afb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -477,7 +477,8 @@ fn (mut g Gen) comptime_for(node ast.ComptimeFor) {
rec_sym := g.table.sym(method.receiver_type)
if rec_sym.kind == .struct_ {
if _ := g.table.find_field_with_embeds(rec_sym, 'Context') {
if method.generic_names.len > 0 {
if method.generic_names.len > 0
|| (method.params.len > 1 && method.attrs.len == 0) {
continue
}
}

View File

@ -92,3 +92,17 @@ fn (mut app App) some_helper<T>(result T) ApiSuccessResponse<T> {
fn (mut app App) ok() vweb.Result {
return app.json(app.some_helper(123))
}
struct ExampleStruct {
example int
}
fn (mut app App) request_raw_2() vweb.Result {
stuff := []ExampleStruct{}
return app.request_raw(stuff)
}
// should compile, this is a helper method, not exposed as a route
fn (mut app App) request_raw(foo []ExampleStruct) vweb.Result {
return app.text('Hello world')
}