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

parser: allow << >> with enums

This commit is contained in:
Alexander Medvednikov 2019-11-14 22:14:04 +03:00
parent a329104dcb
commit a8b5c00939

View File

@ -415,8 +415,11 @@ fn (p mut Parser) expression() string {
return 'void'
}
else {
if !is_integer_type(typ) {
p.error('cannot use shift operator on non-integer type `$typ`')
if !is_integer_type(typ) {
t := p.table.find_type(typ)
if t.cat != .enum_ {
p.error('cannot use shift operator on non-integer type `$typ`')
}
}
p.next()
p.gen(' << ')
@ -425,8 +428,11 @@ fn (p mut Parser) expression() string {
}
}
if p.tok == .righ_shift {
if !is_integer_type(typ) {
p.error('cannot use shift operator on non-integer type `$typ`')
if !is_integer_type(typ) {
t := p.table.find_type(typ)
if t.cat != .enum_ {
p.error('cannot use shift operator on non-integer type `$typ`')
}
}
p.next()
p.gen(' >> ')