markused: fix array append c code dependency (fix #25057) (#25058)

This commit is contained in:
Felipe Pena 2025-08-07 00:32:52 -03:00 committed by GitHub
parent 106da40135
commit afc710e024
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View File

@ -633,6 +633,11 @@ fn (mut w Walker) expr(node_ ast.Expr) {
w.fn_decl(mut &ast.FnDecl(opmethod.source_fn))
}
}
} else {
if !w.uses_append && node.op == .left_shift && (sym.kind == .array
|| (sym.kind == .alias && w.table.final_sym(node.left_type).kind == .array)) {
w.uses_append = true
}
}
}
right_type := if node.right_type == 0 && mut node.right is ast.TypeNode {
@ -658,9 +663,6 @@ fn (mut w Walker) expr(node_ ast.Expr) {
if !w.uses_eq && node.op in [.eq, .ne] {
w.uses_eq = true
}
if !w.uses_append && node.op == .left_shift && !w.is_direct_array_access {
w.uses_append = true
}
}
ast.IfGuardExpr {
w.expr(node.expr)

View File

@ -0,0 +1,7 @@
module main
fn test_main() {
s := 'hello'
arr := s.runes()
assert arr.len == 5
}