checker: add back check struct field fn args

pull/4666/head
joe-conigliaro 2020-05-01 20:12:21 +10:00
parent c1ee14cc3e
commit fb1c60c53d
No known key found for this signature in database
GPG Key ID: C12F7136C08206F1
2 changed files with 7 additions and 5 deletions

View File

@ -65,10 +65,8 @@ fn (pb mut Publisher) publish(name string, sender voidptr, args voidptr) {
if event.once {
pb.registry.events.delete(i)
}
//
x := event.receiver
if x != 0 {
event.handler(x, args, sender)
if event.receiver != 0 {
event.handler(event.receiver, args, sender)
} else {
event.handler(sender, args, voidptr(0))
}

View File

@ -685,13 +685,17 @@ pub fn (mut c Checker) call_method(call_expr mut ast.CallExpr) table.Type {
return table.string_type
}
// call struct field fn type
// TODO: can we use SelectorExpr for all?
// TODO: can we use SelectorExpr for all? this dosent really belong here
if field := c.table.struct_find_field(left_type_sym, method_name) {
field_type_sym := c.table.get_type_symbol(field.typ)
if field_type_sym.kind == .function {
call_expr.is_method = false
info := field_type_sym.info as table.FnType
call_expr.return_type = info.func.return_type
// TODO: check args (do it once for all of the above)
for arg in call_expr.args {
c.expr(arg.expr)
}
return info.func.return_type
}
}