parser: parse type - fix multiple &

pull/4146/head
joe-conigliaro 2020-03-29 01:15:10 +11:00
parent 831be43740
commit 837bffd03a
No known key found for this signature in database
GPG Key ID: C12F7136C08206F1
2 changed files with 12 additions and 7 deletions

View File

@ -753,10 +753,10 @@ fn (g mut Gen) free_scope_vars(pos int) {
// println('//////')
// println(var.name)
// println(var.typ)
if var.typ == 0 {
// TODO why 0?
continue
}
// if var.typ == 0 {
// // TODO why 0?
// continue
// }
sym := g.table.get_type_symbol(var.typ)
if sym.kind == .array && !table.type_is_optional(var.typ) {
g.writeln('array_free($var.name); // autofreed')

View File

@ -94,10 +94,15 @@ pub fn (p mut Parser) parse_type() table.Type {
}
// &Type
mut nr_muls := 0
for p.tok.kind == .amp {
p.check(.amp)
for p.tok.kind in [.and, .amp] {
if p.tok.kind == .and {
nr_muls+=2
}
else {
nr_muls++
}
p.next()
}
if p.tok.kind == .key_mut {
nr_muls++
p.next()