mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
v2: checker: fix --/++
This commit is contained in:
parent
09b7a7c872
commit
3bde876097
@ -633,8 +633,10 @@ pub fn (c mut Checker) postfix_expr(node ast.PostfixExpr) table.Type {
|
||||
}
|
||||
*/
|
||||
typ := c.expr(node.expr)
|
||||
if !table.is_number(typ) {
|
||||
typ_sym := c.table.get_type_symbol(typ)
|
||||
typ_sym := c.table.get_type_symbol(typ)
|
||||
// if !table.is_number(typ) {
|
||||
if !typ_sym.is_number() {
|
||||
println(typ_sym.kind.str())
|
||||
c.error('invalid operation: $node.op.str() (non-numeric type `$typ_sym.name`)', node.pos)
|
||||
}
|
||||
return typ
|
||||
|
@ -799,6 +799,7 @@ pub fn (p mut Parser) expr(precedence int) (ast.Expr,table.Type) {
|
||||
node = ast.PostfixExpr{
|
||||
op: p.tok.kind
|
||||
expr: node
|
||||
pos: p.tok.position()
|
||||
}
|
||||
p.next()
|
||||
return node,typ
|
||||
|
@ -101,10 +101,15 @@ pub const (
|
||||
number_idxs = [int_type_idx, byte_type_idx, u64_type_idx]
|
||||
)
|
||||
|
||||
/*
|
||||
pub fn is_number(typ Type) bool {
|
||||
idx := type_idx(typ)
|
||||
return idx in [int_type_idx, byte_type_idx, u64_type_idx]
|
||||
typ_sym := c.table.get_type_symbol(typ)
|
||||
return typ_sym.is_int()
|
||||
//idx := type_idx(typ)
|
||||
//return idx in [int_type_idx, byte_type_idx, u64_type_idx]
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
pub const (
|
||||
void_type = new_type(void_type_idx)
|
||||
|
Loading…
Reference in New Issue
Block a user