Within a cfmodule, the variables scope is not available within a .each() loop if the .each loop is called in a function within the module.

Description

The variables scope is unavailable within a .each loop if performed within a function within a cfmodule.

To replicate, run test.cfm:

test.cfm

loop.cfm

This will result in an error.

However, if you remove the addData() call altogether and place the code it was executing inline in the file, it works without error.

This runs without error:

loop.cfm

Activity

Show:

Brad Wood February 24, 2025 at 9:20 PM
Edited

Good catch. This issue only affected closures doing lexical variable lookups inside a function that wasn’t part of a class.

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Fix versions

Affects versions

Priority

Sentry

Created February 23, 2025 at 7:52 PM
Updated February 24, 2025 at 9:21 PM
Resolved February 24, 2025 at 9:21 PM