cgen: fix const declaration dependant mapping when using update_expr (fix #24437) (#24455)

This commit is contained in:
Felipe Pena 2025-05-10 14:53:37 -03:00 committed by GitHub
parent 3b8f2fe5f5
commit 00ef1a6c52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 0 deletions

View File

@ -2601,6 +2601,9 @@ pub fn (t &Table) dependent_names_in_expr(expr Expr) []string {
names << t.dependent_names_in_expr(expr.expr)
}
StructInit {
if expr.has_update_expr {
names << t.dependent_names_in_expr(expr.update_expr)
}
for field in expr.init_fields {
names << t.dependent_names_in_expr(field.expr)
}

View File

@ -0,0 +1,17 @@
struct Cfg {
id string
name string
}
pub const cfg1 = Cfg{
...cfg0
name: 'name1'
}
pub const cfg0 = Cfg{
id: 'cfg0'
name: 'name'
}
fn test_main() {
assert cfg1.id == 'cfg0'
}