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

checker: allow operator overloading on strings (p. 1) (#10182)

This commit is contained in:
Enzo 2021-05-24 09:23:57 +02:00 committed by GitHub
parent d8d05e0106
commit c0b1f99935
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7093,7 +7093,11 @@ fn (mut c Checker) fn_decl(mut node ast.FnDecl) {
} else { } else {
receiver_sym := c.table.get_type_symbol(node.receiver.typ) receiver_sym := c.table.get_type_symbol(node.receiver.typ)
param_sym := c.table.get_type_symbol(node.params[1].typ) param_sym := c.table.get_type_symbol(node.params[1].typ)
if param_sym.kind !in [.struct_, .alias] || receiver_sym.kind !in [.struct_, .alias] { if param_sym.kind == .string && receiver_sym.kind == .string {
// bypass check for strings
// TODO there must be a better way to handle that
} else if param_sym.kind !in [.struct_, .alias]
|| receiver_sym.kind !in [.struct_, .alias] {
c.error('operator methods are only allowed for struct and type alias', c.error('operator methods are only allowed for struct and type alias',
node.pos) node.pos)
} else { } else {