checker: fix error of for_in alias (#10770)
parent
de9aa987bc
commit
5c7881feb7
|
@ -4358,7 +4358,7 @@ fn (mut c Checker) for_in_stmt(mut node ast.ForInStmt) {
|
||||||
}
|
}
|
||||||
node.scope.update_var_type(node.val_var, node.val_type)
|
node.scope.update_var_type(node.val_var, node.val_type)
|
||||||
} else {
|
} else {
|
||||||
sym := c.table.get_type_symbol(typ)
|
sym := c.table.get_final_type_symbol(typ)
|
||||||
if sym.kind == .struct_ {
|
if sym.kind == .struct_ {
|
||||||
// iterators
|
// iterators
|
||||||
next_fn := sym.find_method('next') or {
|
next_fn := sym.find_method('next') or {
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
enum Nucleotide {
|
||||||
|
a
|
||||||
|
c
|
||||||
|
g
|
||||||
|
t
|
||||||
|
}
|
||||||
|
|
||||||
|
type Codon = []Nucleotide
|
||||||
|
type Gene = []Codon
|
||||||
|
|
||||||
|
fn test_for_in_alias() {
|
||||||
|
mut gene := Gene([
|
||||||
|
Codon([Nucleotide.a, Nucleotide.c, Nucleotide.g]),
|
||||||
|
Codon([Nucleotide.g, Nucleotide.a, Nucleotide.t]),
|
||||||
|
])
|
||||||
|
|
||||||
|
mut ret := []string{}
|
||||||
|
for cdn in gene {
|
||||||
|
println(cdn)
|
||||||
|
ret << '$cdn'
|
||||||
|
}
|
||||||
|
|
||||||
|
assert ret.len == 2
|
||||||
|
assert ret[0] == 'Codon([a, c, g])'
|
||||||
|
assert ret[1] == 'Codon([g, a, t])'
|
||||||
|
}
|
Loading…
Reference in New Issue