mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: handle !is
in error messages
This commit is contained in:
parent
206e64d72c
commit
a3a91f54a9
@ -553,10 +553,10 @@ pub fn (mut c Checker) infix_expr(mut infix_expr ast.InfixExpr) table.Type {
|
|||||||
type_expr := infix_expr.right as ast.Type
|
type_expr := infix_expr.right as ast.Type
|
||||||
typ_sym := c.table.get_type_symbol(type_expr.typ)
|
typ_sym := c.table.get_type_symbol(type_expr.typ)
|
||||||
if typ_sym.kind == .placeholder {
|
if typ_sym.kind == .placeholder {
|
||||||
c.error('is: type `${typ_sym.name}` does not exist', type_expr.pos)
|
c.error('$infix_expr.op.str(): type `${typ_sym.name}` does not exist', type_expr.pos)
|
||||||
}
|
}
|
||||||
if left.kind != .interface_ && left.kind != .sum_type {
|
if left.kind != .interface_ && left.kind != .sum_type {
|
||||||
c.error('`is` can only be used with interfaces and sum types', type_expr.pos)
|
c.error('`$infix_expr.op.str()` can only be used with interfaces and sum types', type_expr.pos)
|
||||||
}
|
}
|
||||||
return table.bool_type
|
return table.bool_type
|
||||||
}
|
}
|
||||||
@ -580,7 +580,7 @@ pub fn (mut c Checker) infix_expr(mut infix_expr ast.InfixExpr) table.Type {
|
|||||||
} else if left_type == table.string_type && infix_expr.op !in [.plus, .eq, .ne, .lt, .gt,
|
} else if left_type == table.string_type && infix_expr.op !in [.plus, .eq, .ne, .lt, .gt,
|
||||||
.le, .ge] {
|
.le, .ge] {
|
||||||
// TODO broken !in
|
// TODO broken !in
|
||||||
c.error('string types only have the following operators defined: `==`, `!=`, `<`, `>`, `<=`, `>=`, and `&&`',
|
c.error('string types only have the following operators defined: `==`, `!=`, `<`, `>`, `<=`, `>=`, and `+`',
|
||||||
infix_expr.pos)
|
infix_expr.pos)
|
||||||
}
|
}
|
||||||
// Dual sides check (compatibility check)
|
// Dual sides check (compatibility check)
|
||||||
|
Loading…
Reference in New Issue
Block a user