mirror of
https://github.com/vlang/v.git
synced 2025-09-11 08:25:42 -04:00
parent
2bd2d00caf
commit
a831ec77d3
@ -705,7 +705,8 @@ pub fn (mut w Walker) call_expr(mut node ast.CallExpr) {
|
|||||||
w.expr(node.left)
|
w.expr(node.left)
|
||||||
w.or_block(node.or_block)
|
w.or_block(node.or_block)
|
||||||
|
|
||||||
fn_name := node.fkey()
|
mut fn_name := node.fkey()
|
||||||
|
mut receiver_typ := node.receiver_type
|
||||||
if w.used_fns[fn_name] {
|
if w.used_fns[fn_name] {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -735,12 +736,13 @@ pub fn (mut w Walker) call_expr(mut node ast.CallExpr) {
|
|||||||
&& !node.receiver_concrete_type.has_flag(.generic) {
|
&& !node.receiver_concrete_type.has_flag(.generic) {
|
||||||
// if receiver is generic, then cgen requires `node.receiver_type` to be T.
|
// if receiver is generic, then cgen requires `node.receiver_type` to be T.
|
||||||
// We therefore need to get the concrete type from `node.receiver_concrete_type`.
|
// We therefore need to get the concrete type from `node.receiver_concrete_type`.
|
||||||
fkey := '${int(node.receiver_concrete_type)}.${node.name}'
|
fn_name = '${int(node.receiver_concrete_type)}.${node.name}'
|
||||||
w.mark_fn_as_used(fkey)
|
receiver_typ = node.receiver_concrete_type
|
||||||
|
w.mark_fn_as_used(fn_name)
|
||||||
}
|
}
|
||||||
stmt := w.all_fns[fn_name] or { return }
|
stmt := w.all_fns[fn_name] or { return }
|
||||||
if stmt.name == node.name {
|
if stmt.name == node.name {
|
||||||
if !node.is_method || node.receiver_type == stmt.receiver.typ {
|
if !node.is_method || receiver_typ == stmt.receiver.typ {
|
||||||
w.stmts(stmt.stmts)
|
w.stmts(stmt.stmts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
36
vlib/v/tests/skip_unused/generic_call_from_json.vv
Normal file
36
vlib/v/tests/skip_unused/generic_call_from_json.vv
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import veb
|
||||||
|
import x.json2
|
||||||
|
|
||||||
|
pub struct Context {
|
||||||
|
veb.Context
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct App {
|
||||||
|
veb.Middleware[Context]
|
||||||
|
}
|
||||||
|
|
||||||
|
@['/'; POST]
|
||||||
|
fn (app &App) index(mut ctx Context) veb.Result {
|
||||||
|
j := json2.raw_decode(ctx.req.data) or { return ctx.request_error('error') }
|
||||||
|
|
||||||
|
m := j.as_map()
|
||||||
|
myarr := m['myarr'] or { panic(error) }
|
||||||
|
m2 := myarr.arr()
|
||||||
|
|
||||||
|
for mc in m2 {
|
||||||
|
parts := mc.arr()
|
||||||
|
|
||||||
|
// Compiler error occurs here -->
|
||||||
|
first := parts[0].str()
|
||||||
|
second := parts[1].str()
|
||||||
|
third := parts[2].str()
|
||||||
|
|
||||||
|
println('1. ${first}, 2. ${second}, 3. ${third}')
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.ok('ok')
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
_ := &App{}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user