Skip to content

fix: handle children = [...] ++ expr in add_new_child#368

Merged
zachdaniel merged 1 commit intomainfrom
fix/add-child-list-concatenation
Mar 24, 2026
Merged

fix: handle children = [...] ++ expr in add_new_child#368
zachdaniel merged 1 commit intomainfrom
fix/add-child-list-concatenation

Conversation

@jimsynz
Copy link
Copy Markdown
Contributor

@jimsynz jimsynz commented Mar 23, 2026

Summary

  • add_new_child/3 now handles Application modules where the children assignment uses list concatenation (children = [...] ++ target_children()), which is the standard pattern generated by mix nerves.new
  • Extracts shared insert/duplicate-detection logic into add_child_to_list/4 to avoid duplication between the simple list and ++ code paths
  • Only the [...] ++ expr form is handled (list on the left); the reverse expr ++ [...] is not matched

Test plan

  • New test: adds a child when children list uses ++ concatenation
  • New test: duplicate detection works with ++ concatenation
  • All 26 existing application tests pass
  • Full test suite passes (306 tests, 0 failures)
  • Manually verified against a Nerves project

`add_new_child` failed to insert children when the Application module
used list concatenation (e.g. `children = [...] ++ target_children()`),
which is the standard pattern generated by `mix nerves.new`.

The `children = expr` match required the RHS to be a literal list, but
with `++` the AST node is a function call. This adds a fallback that
matches `children = [...] ++ expr` and navigates into the literal list
(first operand of `++`) as the insertion target.
@jimsynz jimsynz requested a review from zachdaniel March 23, 2026 21:49
@zachdaniel zachdaniel merged commit 6b0fd76 into main Mar 24, 2026
88 of 89 checks passed
@zachdaniel
Copy link
Copy Markdown
Contributor

🚀 Thank you for your contribution! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants