Thanks to visit codestin.com
Credit goes to github.com

Skip to content

WIP: Force init/fini AST nodes to the beginning/end of their siblings#4956

Draft
Cisphyx wants to merge 1 commit into
masterfrom
initfini-ordering
Draft

WIP: Force init/fini AST nodes to the beginning/end of their siblings#4956
Cisphyx wants to merge 1 commit into
masterfrom
initfini-ordering

Conversation

@Cisphyx

@Cisphyx Cisphyx commented May 22, 2026

Copy link
Copy Markdown
Contributor
[inet:ipv4=1.1.1.1 inet:ipv4=2.2.2.2] |

init {
    $gronk = "newp"
    $global_count = 0
}

for $x in (["one", "two", "three"]) {
    $gronk = $x
    $global_count = ($global_count + 1)
}
$lib.print($gronk)
$lib.print($global_count)
  1. inet:ipv4=1.1.1.1 is created and its path is initialized, but there are no runtime vars so it gets no path vars
  2. the init is run, setting $global_count=0, before yielding the 1.1.1.1 node further
  3. at the start of the loop, the node+path is cloned for each iteration, but at this point the path has no vars set yet
  4. inside the loop $global_count is pulled from the runtime since each clone of the path does not have it set, this causes it to be incremented from 0 -> 1 -> 2 -> 3 in the 3 iterations
  5. we reach the bottom of query and print $global_count which has a value of 3
  6. inet:ipv4=1.1.1.1 is created and its path is initialized, there are now runtime vars set so $global_count is set to 3 on the path from the value on the runtime
  7. the init has already been run so nothing happens and the 2.2.2.2 continues on
  8. at the start of the loop, this time we do have path vars, so each clone of the path has $global_count set to 3
  9. inside the loop, $global_count is now pulled from the path rather than the runtime, so each iteration of the loop only increments the value from 3 -> 4
  10. we reach the bottom of query and print $global_count which has a value of 4

@codecov

codecov Bot commented May 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.75%. Comparing base (3d9fbeb) to head (fac2002).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4956      +/-   ##
==========================================
- Coverage   97.79%   97.75%   -0.05%     
==========================================
  Files         299      299              
  Lines       63367    63370       +3     
==========================================
- Hits        61971    61947      -24     
- Misses       1396     1423      +27     
Flag Coverage Δ
linux 97.68% <100.00%> (-0.02%) ⬇️
linux_replay 93.50% <100.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant