checker: fn arg - disallow any type with .str() to be passed as string
parent
837df7c074
commit
cff2874608
|
@ -851,9 +851,9 @@ pub fn (mut c Checker) call_method(mut call_expr ast.CallExpr) table.Type {
|
||||||
if !c.check_types(got_arg_typ, exp_arg_typ) {
|
if !c.check_types(got_arg_typ, exp_arg_typ) {
|
||||||
got_arg_sym := c.table.get_type_symbol(got_arg_typ)
|
got_arg_sym := c.table.get_type_symbol(got_arg_typ)
|
||||||
// str method, allow type with str method if fn arg is string
|
// str method, allow type with str method if fn arg is string
|
||||||
if exp_arg_sym.kind == .string && got_arg_sym.has_method('str') {
|
// if exp_arg_sym.kind == .string && got_arg_sym.has_method('str') {
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
if got_arg_typ != table.void_type {
|
if got_arg_typ != table.void_type {
|
||||||
c.error('cannot use type `$got_arg_sym.str()` as type `$exp_arg_sym.str()` in argument ${i+1} to `${left_type_sym.name}.$method_name`',
|
c.error('cannot use type `$got_arg_sym.str()` as type `$exp_arg_sym.str()` in argument ${i+1} to `${left_type_sym.name}.$method_name`',
|
||||||
call_expr.pos)
|
call_expr.pos)
|
||||||
|
|
Loading…
Reference in New Issue