tracker issue : CF-4126691

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

The logic of the new Safe Navigation operator (?.) is inconsistent

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/NotABug

Reporter/Name(from Bugbase): A. Bakia / A. Bakia (A. Bakia)

Created: 03/09/2016

Components: Language

Versions: 2016

Failure Type: Unspecified

Found In Build/Fixed In Build: Alpha_v12 /

Priority/Frequency: Trivial / Unknown

Locale/System: English / Win All

Vote Count: 1

Problem Description: According to the new Safe Navigation operator (?.), the expression,

<cfoutput>#employee?.getDesignation#</cfoutput>

is equivalent to

<cfif isDefined('variables.employee') and structKeyExists(employee,'getDesignation')>
<cfoutput>#employee.getDesignation#</cfoutput>
<cfelse>
</cfif>

This logic is inconsistent, as it implies that an undefined variable is equal to an empty string.

Steps to Reproduce: Run a CFM page containing just this line:
noneExistentStructure?.arbitraryKeyName is '': <cfoutput>#noneExistentStructure?.arbitraryKeyName is ''#</cfoutput>

Actual Result: 
noneExistentStructure?.arbitraryKeyName is '': YES


Expected Result: I expect no such operator, and would discourage its use. It is analogous to an attempt to mask smoke. The undefinedness of a variable is a reminder there is a fire to attend to.   

Any Workarounds:

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

Watson Bug ID:	4126691

External Customer Info:
External Company: (withheld for privacy)
External Customer Name: A. Bakia
External Customer Email: A.BAKIG@CHELLO.NL
External Test Config:

Attachments:

Comments:

Adding BUG AUDIT TRAIL ********action: updated fieldName: State newValue: Closed oldValue: Open oprid: suchsing recordName: RQ_DEFECT timpestamp: 2015-07-20 05:37:01.0 action: updated fieldName: Closed By newValue: suchsing oldValue: Blank oprid: suchsing recordName: RQ_DEFECT timpestamp: 2015-07-20 05:37:01.0 action: updated fieldName: Status newValue: Withdrawn oldValue: Unverified oprid: suchsing recordName: RQ_DEFECT timpestamp: 2015-07-20 05:37:01.0 action: updated fieldName: Date Closed newValue: 2015-07-19 22:37:01.0 oldValue: Blank oprid: suchsing recordName: RQ_DEFECT timpestamp: 2015-07-20 05:37:01.0 action: updated fieldName: Reason newValue: NotABug oldValue: Blank oprid: suchsing recordName: RQ_DEFECT timpestamp: 2015-07-20 05:37:01.0 action: updated fieldName: Owner newValue: Blank oldValue: suchsing oprid: suchsing recordName: RQ_DEFECT timpestamp: 2015-07-20 05:37:01.0 action: updated fieldName: Owner newValue: suchsing oldValue: inoel oprid: vmannebo recordName: RQ_DEFECT timpestamp: 2015-07-20 04:00:16.0 action: updated fieldName: QE Assigned newValue: suchsing oldValue: inoel oprid: vmannebo recordName: RQ_DEFECT timpestamp: 2015-07-20 04:00:16.0
Comment by CFwatson U.
3493 | March 09, 2016 04:39:05 AM GMT
Added By:suchsing Note Added: This is by design and mentioned in the documentation. Date Added :2015-07-20 05:37:01.0 Added By: PreRelease User User Name:A. Bakia Note Added: Entered Bug. Date Added :2015-07-19 13:52:15.0
Comment by CFwatson U.
3494 | March 09, 2016 04:39:07 AM GMT