sum type: mut

pull/3635/head
Alexander Medvednikov 2020-02-03 09:25:26 +01:00
parent 34e9eb32bb
commit 50b704c5dd
2 changed files with 7 additions and 1 deletions

View File

@ -12,6 +12,11 @@ import (
fn (p mut Parser) match_statement(is_expr bool) string {
p.check(.key_match)
p.fspace()
is_mut := p.tok == .key_mut
if is_mut {
p.next()
p.fspace()
}
typ,expr := p.tmp_expr()
if typ.starts_with('array_') {
p.error('arrays cannot be compared')
@ -140,7 +145,7 @@ fn (p mut Parser) match_statement(is_expr bool) string {
p.register_var(Var{
name: 'it'
typ: sum_child_type+'*'
is_mut: true
is_mut: is_mut
ptr: true
})
}

View File

@ -197,6 +197,7 @@ fn (c &Checker) stmt(node ast.Stmt) {
}
ast.VarDecl {
typ := c.expr(it.expr)
// it.typ = typ
// println('checker: var decl $typ.name it.typ=$it.typ.name $it.pos.line_nr')
/*
if typ.kind != .void {