tracker issue : CF-4194596

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

Elvis operator with struct literal as second operand returns "{"

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Bradley Wood / Bradley Wood (Bradley Wood)

Created: 10/01/2016

Components: Language

Versions: 2016,11.0

Failure Type:

Found In Build/Fixed In Build: CF11_Final / 2018,0,0,308513

Priority/Frequency: Major / All users will encounter

Locale/System: ALL / Platforms All

Vote Count: 2

Problem Description:
Passing a struct literal as the second operand to the Elvis operator returns the string "{" instead of an empty struct.  I've tested this on CF11 update 10.

Steps to Reproduce:
x = y ?: {};
writeDump(x); 

Actual Result:
The string "{"

Expected Result:
An empty struct

Any Workarounds:
x = y ?: structNew();
writeDump(x);

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4194596

Reason:	BugVerified

External Customer Info:
External Company:  
External Customer Name: Bradley Wood
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

It impacts productivity because it doesn't error but sets your data to {, how on earth was this not picked up. I mean even the most basic test case should have nailed this
Vote by External U.
1705 | October 25, 2016 03:20:03 PM GMT
This is also an issue with explicit arrays: writeDump(z ?: []) actual: "[" expected: an empty array workaround: writeDump(z ?: arrayNew(1)) CF Build: 11,0,12,302575 In CF 2016 (build 2016,0,03,301771) this results in an error: coldfusion.runtime.UndefinedVariableException: Variable ___IMPLICITARRYSTRUCTVAR1 is undefined. at coldfusion.runtime.CfJspPage._get(CfJspPage.java:349) at coldfusion.runtime.CfJspPage._get(CfJspPage.java:328) at coldfusion.runtime.CfJspPage._get(CfJspPage.java:315) at coldfusion.runtime.CfJspPage._autoscalarize(CfJspPage.java:1792) at coldfusion.runtime.CfJspPage._autoscalarize(CfJspPage.java:1754) at cfscratchCode92197773230984633702etmp714619082$func_CF_ANONYMOUSCLOSURE_ELVIS300.runFunction(C:\scratchCode9219777323098463370.tmp:2)
Comment by Bryan H.
1704 | June 21, 2017 10:17:12 PM GMT
causes runtime error in CF 2016 update 3
Vote by Bryan H.
1706 | June 21, 2017 10:18:12 PM GMT