cgen: fix array of alias's slice() (#10772)
parent
b09fa69cb3
commit
1b26ce1f7a
|
@ -58,7 +58,7 @@ fn (mut g Gen) index_expr(node ast.IndexExpr) {
|
|||
}
|
||||
|
||||
fn (mut g Gen) range_expr(node ast.IndexExpr, range ast.RangeExpr) {
|
||||
sym := g.table.get_type_symbol(node.left_type)
|
||||
sym := g.table.get_final_type_symbol(node.left_type)
|
||||
if sym.kind == .string {
|
||||
g.write('string_substr(')
|
||||
g.expr(node.left)
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
type Ints = []int
|
||||
|
||||
fn (i Ints) slice(to int) Ints {
|
||||
return i[0..to]
|
||||
}
|
||||
|
||||
fn test_array_of_alias_slice() {
|
||||
values := Ints([5, 7, 9])
|
||||
|
||||
println(values.slice(2))
|
||||
assert values.slice(2) == Ints([5, 7])
|
||||
}
|
Loading…
Reference in New Issue