Skip to content

Broken testitem: the scan's expectation test errors on a soft-scope UndefVarError #371

Closed

Description

@seabbs-bot

The testitem "the scan's expectation stops at the first modifier that draws" in
test/unit/infection_models/renewal_step.jl:265 errors instead of running.

the scan's expectation stops at the first modifier that draws: Error During Test
  at test/unit/infection_models/renewal_step.jl:265
  Got exception outside of a @test
  LoadError: UndefVarError: `window` not defined in local scope
  Suggestion: check for an assignment to a local variable that shadows a global of the same name.
  Stacktrace:
   [1] top-level scope
     @ test/unit/infection_models/renewal_step.jl:293

The reference recurrence binds window and S at the testitem's top level and
then reassigns both inside the loop.

window, S = init.window, N
for R in Rt
    foi = renewal_foi(core, window, R)   # line 293
    ...
    S -= depleted
    window = vcat(window[2:end], draw)
end

Julia's soft-scope rule makes an assignment inside a loop create a new local
when the run is not interactive, so line 293 reads window before it is bound.
Wrapping the recurrence in a let block or a small function fixes it.

This matters because the testitem is the one that pins the recorded expectation
against all three of the bare force of infection, the post-depletion incidence
and the committed draw.
That is the case #337 got wrong, so the property is currently unverified.

Found on 289-noise (#348).
The testitem arrived in 9a01bdc and the last Test workflow run on that branch
was at 503cf5a, one commit earlier, so no CI run has ever exercised it.
origin/main does not carry the testitem and the file passes there.

This was opened by a bot. Please ping @seabbs for any questions.

Activity

  1. seabbs-bot commented on Sep 4, 2026

    @seabbs-bot
    CollaboratorAuthor

    Fixed on 289-noise in the InfectionNoise PR (#348) rather than deferred, since the testitem pins the property that PR exists to establish.

    The recurrence is now bound in a let block, with a comment saying why it is load-bearing. renewal_step.jl goes from 58 pass / 1 error to 62 pass / 0 errors.

    Worth recording the reason it went unnoticed: the last Test workflow run on the branch was at 503cf5a2, one commit before the testitem arrived, so CI had never executed it.

    This was opened by a bot. Please ping @seabbs for any questions.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions