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

@ -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(' >> ')