Cannot set calling scope vars from closures when localMode="modern"

Description

Consider this code:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 <cfscript> function doSomething ( any onComplete) { writeOutput("<p>I just did something!</p>"); onComplete(); } function test () { var myVar = ""; writeOutput("<p>Before closure: [#myVar#]</p>"); doSomething(function () { myVar = "test"; }); writeOutput("<p>After closure: [#myVar#]</p>"); } test(); </cfscript>

In application.cfc, when this.localMode="modern", the test fails to persist the change made to myVar. When turned off, it works as expected.

Environment

None

Status

Assignee

Michael Offner

Reporter

JP

Labels

None

Affects versions

5.3.2.41

Priority

Major
Configure