v2: checker: fix --/++
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)
|
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)
|
c.error('invalid operation: $node.op.str() (non-numeric type `$typ_sym.name`)', node.pos)
|
||||||
}
|
}
|
||||||
return typ
|
return typ
|
||||||
|
|
|
@ -799,6 +799,7 @@ pub fn (p mut Parser) expr(precedence int) (ast.Expr,table.Type) {
|
||||||
node = ast.PostfixExpr{
|
node = ast.PostfixExpr{
|
||||||
op: p.tok.kind
|
op: p.tok.kind
|
||||||
expr: node
|
expr: node
|
||||||
|
pos: p.tok.position()
|
||||||
}
|
}
|
||||||
p.next()
|
p.next()
|
||||||
return node,typ
|
return node,typ
|
||||||
|
|
|
@ -101,10 +101,15 @@ pub const (
|
||||||
number_idxs = [int_type_idx, byte_type_idx, u64_type_idx]
|
number_idxs = [int_type_idx, byte_type_idx, u64_type_idx]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
pub fn is_number(typ Type) bool {
|
pub fn is_number(typ Type) bool {
|
||||||
idx := type_idx(typ)
|
typ_sym := c.table.get_type_symbol(typ)
|
||||||
return idx in [int_type_idx, byte_type_idx, u64_type_idx]
|
return typ_sym.is_int()
|
||||||
|
//idx := type_idx(typ)
|
||||||
|
//return idx in [int_type_idx, byte_type_idx, u64_type_idx]
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
pub const (
|
pub const (
|
||||||
void_type = new_type(void_type_idx)
|
void_type = new_type(void_type_idx)
|
||||||
|
|
Loading…
Reference in New Issue