parser: allow << >> with enums

pull/2764/head
Alexander Medvednikov 2019-11-14 22:14:04 +03:00
parent a329104dcb
commit a8b5c00939
1 changed files with 10 additions and 4 deletions

View File

@ -416,8 +416,11 @@ fn (p mut Parser) expression() string {
} }
else { else {
if !is_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.error('cannot use shift operator on non-integer type `$typ`')
} }
}
p.next() p.next()
p.gen(' << ') p.gen(' << ')
p.check_types(p.expression(), 'integer') p.check_types(p.expression(), 'integer')
@ -426,8 +429,11 @@ fn (p mut Parser) expression() string {
} }
if p.tok == .righ_shift { if p.tok == .righ_shift {
if !is_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.error('cannot use shift operator on non-integer type `$typ`')
} }
}
p.next() p.next()
p.gen(' >> ') p.gen(' >> ')
p.check_types(p.expression(), 'integer') p.check_types(p.expression(), 'integer')