mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
v2: postfix_expr() checker
This commit is contained in:
parent
4d6958381d
commit
c7f07cd0b6
@ -235,6 +235,7 @@ pub struct PostfixExpr {
|
||||
pub:
|
||||
op token.Kind
|
||||
expr Expr
|
||||
pos token.Position
|
||||
}
|
||||
|
||||
pub struct PrefixExpr {
|
||||
|
@ -242,7 +242,7 @@ pub fn (c &Checker) expr(node ast.Expr) table.Type {
|
||||
}
|
||||
// ast.FloatLiteral {}
|
||||
ast.PostfixExpr {
|
||||
return c.expr(it.expr)
|
||||
return c.postfix_expr(it)
|
||||
}
|
||||
/*
|
||||
ast.UnaryExpr {
|
||||
@ -309,6 +309,22 @@ pub fn (c &Checker) expr(node ast.Expr) table.Type {
|
||||
return table.void_type
|
||||
}
|
||||
|
||||
pub fn (c &Checker) postfix_expr(node ast.PostfixExpr) table.Type {
|
||||
/*
|
||||
match node.expr {
|
||||
ast.IdentVar {
|
||||
println('postfix identvar')
|
||||
}
|
||||
else {}
|
||||
}
|
||||
*/
|
||||
typ := c.expr(node.expr)
|
||||
if typ.kind != .int {
|
||||
c.error('invalid operation: $node.op.str() (non-numeric type `$typ.name`)', node.pos)
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
pub fn (c &Checker) index_expr(node ast.IndexExpr) table.Type {
|
||||
mut typ := c.expr(node.left)
|
||||
mut is_range := false // TODO is_range := node.index is ast.RangeExpr
|
||||
|
Loading…
Reference in New Issue
Block a user