@@ -548,7 +548,7 @@ fn (mut c Checker) sum_type_decl(node ast.SumTypeDecl) {
548
548
c.error ('sum type cannot hold a reference type' , variant.pos)
549
549
}
550
550
c.ensure_type_exists (variant.typ, variant.pos) or {}
551
- mut sym := c.table.sym (variant.typ)
551
+ sym := c.table.sym (variant.typ)
552
552
if sym.name in names_used {
553
553
c.error ('sum type ${node.name} cannot hold the type `${sym.name} ` more than once' ,
554
554
variant.pos)
@@ -558,7 +558,7 @@ fn (mut c Checker) sum_type_decl(node ast.SumTypeDecl) {
558
558
c.error ('sum type cannot hold an interface' , variant.pos)
559
559
} else if sym.kind == .struct_ && sym.language == .js {
560
560
c.error ('sum type cannot hold a JS struct' , variant.pos)
561
- } else if mut sym.info is ast.Struct {
561
+ } else if sym.info is ast.Struct {
562
562
if sym.info.is_generic {
563
563
if ! variant.typ.has_flag (.generic) {
564
564
c.error ('generic struct `${sym.name} ` must specify generic type names, e.g. ${sym.name} [T]' ,
@@ -581,11 +581,10 @@ fn (mut c Checker) sum_type_decl(node ast.SumTypeDecl) {
581
581
}
582
582
}
583
583
} else if sym.info is ast.FnType {
584
- func := (sym.info as ast.FnType ).func
585
- if c.table.sym (func.return_type).name.ends_with ('.${node.name} ' ) {
584
+ if c.table.sym (sym.info.func.return_type).name.ends_with ('.${node.name} ' ) {
586
585
c.error ('sum type `${node.name} ` cannot be defined recursively' , variant.pos)
587
586
}
588
- for param in func.params {
587
+ for param in sym.info. func.params {
589
588
if c.table.sym (param.typ).name.ends_with ('.${node.name} ' ) {
590
589
c.error ('sum type `${node.name} ` cannot be defined recursively' , variant.pos)
591
590
}
0 commit comments