checker: fix warning at comptime call (#8248)

pull/8244/head
Louis Schmieder 2021-01-21 20:36:11 +01:00 committed by GitHub
parent 0d204603d1
commit 6b1956fb60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View File

@ -3605,6 +3605,11 @@ fn (mut c Checker) comptime_call(mut node ast.ComptimeCall) table.Type {
if node.method_name == 'html' {
return c.table.find_type_idx('vweb.Result')
}
mut var := c.fn_scope.objects[node.method_name]
if mut var is ast.Var {
var.is_used = true
c.fn_scope.objects[node.method_name] = var
}
return table.string_type
}

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,11 @@
struct Test {}
fn (test Test) print() {
println('test')
}
fn main() {
test := Test{}
abc := 'print'
test.$abc()
}