tracker issue : CF-4203530

select a category, or use search below
(searches all categories and all time range)
Title:

RandRange does not sum correctly in struct with shorthand addition

| View in Tracker

Status/Resolution/Reason: Open//

Reporter/Name(from Bugbase): Daniel Roberts / ()

Created: 11/26/2018

Components: Language, Expressions

Versions: 2016

Failure Type: Incorrect w/Workaround

Found In Build/Fixed In Build: multiple /

Priority/Frequency: Normal / Very few users will encounter

Locale/System: / Windows 7 64-bit

Vote Count: 0

Problem Description:

- When passing RandRange function as struct key value and using shorthand addition notation, the struct values do not sum correctly.

Steps to Reproduce:

<cfset checks = {1=0, 2=0, count=0} />
<cfloop from="1" to="1000" index="ix">
    <cfset checks["count"] += 1 />
    <cfset checks["#randrange(1,2)#"] += 1 />
</cfloop>
<cfdump var="#checks#" format="text" />

Actual Result:

struct
1: 526
2: 527
COUNT: 1000

- When looping over a struct with random addition for two values the total should be the same as the number of loop iterations. However the total is usually many more or less than the number of iterations. 

Expected Result:

- Adding accumulated values should total the count but they never do.

Any Workarounds:

- setting the RandRange result to a variable first and then passing as the struct key doesn't present the problem
- if incrementing by 1 then the increment ++ operator acts correctly

Attachments:

Comments: