Skip to content

Commit f177237

Browse files
authored
cgen: fix const indexexpr dep (fix #24850) (#24851)
1 parent 57aae3f commit f177237

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

‎vlib/v/ast/table.v‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2557,6 +2557,9 @@ pub fn (t &Table) dependent_names_in_expr(expr Expr) []string {
25572557
names << util.no_dots(expr.name)
25582558
}
25592559
}
2560+
IndexExpr {
2561+
names << t.dependent_names_in_expr(expr.left)
2562+
}
25602563
IfExpr {
25612564
for branch in expr.branches {
25622565
names << t.dependent_names_in_expr(branch.cond)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const array1 = [1]
2+
const array2 = [array1]
3+
const array3 = array2[0]
4+
5+
fn test_main() {
6+
assert array3 == array1
7+
}

0 commit comments

Comments
 (0)