tracker issue : CF-4126681

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

Complete Safe Navigation Operator Implementation

| View in Tracker

Status/Resolution/Reason: Closed/Won't Fix/

Reporter/Name(from Bugbase): Nicholas Tunney / Nicholas Tunney (Nicholas Tunney)

Created: 03/09/2016

Components: Language

Versions: 2016

Failure Type: Unspecified

Found In Build/Fixed In Build: Alpha_v12 /

Priority/Frequency: Normal / Unknown

Locale/System: English / Mac All

Vote Count: 13

I'd like to propose that a ? safe navigation operator is added to handle array notation.  An example is included below on line 5:

1: <cfscript>
2:  st = {};
3:  st.key1 = "My Value";
4:  writeDump(st?.key1);
5:  writeDump(st?["key1"]);
6: </cfscript>

This would work exactly like ?. works for dot notation on line 4, and would round out the functionality.  Currently this throws a parse error.  I know that C# has this functionality, and maybe other languages do as well.  Seems pretty useful to me.

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

Watson Bug ID:	4126681

External Customer Info:
External Company: AboutWeb, LLC
External Customer Name: Nicholas Tunney
External Customer Email: NIC.TUNNEY@NICTUNNEY.COM
External Test Config:

Attachments:

Comments:

Adding BUG AUDIT TRAIL ********action: updated fieldName: Date Closed newValue: 2015-10-06 04:36:55.0 oldValue: Blank oprid: suchsing recordName: RQ_DEFECT timpestamp: 2015-10-06 11:36:55.0 action: updated fieldName: Closed By newValue: suchsing oldValue: Blank oprid: suchsing recordName: RQ_DEFECT timpestamp: 2015-10-06 11:36:55.0 action: updated fieldName: Owner newValue: Blank oldValue: suchsing oprid: suchsing recordName: RQ_DEFECT timpestamp: 2015-10-06 11:36:55.0 action: updated fieldName: State newValue: Closed oldValue: Open oprid: suchsing recordName: RQ_DEFECT timpestamp: 2015-10-06 11:36:55.0 action: updated fieldName: Status newValue: NeverFix oldValue: ToTest oprid: suchsing recordName: RQ_DEFECT timpestamp: 2015-10-06 11:36:55.0 action: updated fieldName: Reason newValue: Blank oldValue: NeverFix oprid: suchsing recordName: RQ_DEFECT timpestamp: 2015-10-06 11:36:55.0 action: updated fieldName: Owner newValue: suchsing oldValue: mchandna oprid: mchandna recordName: RQ_DEFECT timpestamp: 2015-10-01 13:59:43.0 action: updated fieldName: Status newValue: ToTest oldValue: ToFix oprid: mchandna recordName: RQ_DEFECT timpestamp: 2015-10-01 13:59:43.0 action: updated fieldName: Reason newValue: NeverFix oldValue: Blank oprid: mchandna recordName: RQ_DEFECT timpestamp: 2015-10-01 13:59:43.0 action: updated fieldName: Priority newValue: 2 oldValue: 0 oprid: vmannebo recordName: RQ_DEFECT timpestamp: 2015-09-10 04:45:16.0 action: updated fieldName: Status newValue: ToFix oldValue: NeedsReview oprid: vmannebo recordName: RQ_DEFECT timpestamp: 2015-09-08 09:05:07.0 action: updated fieldName: Reason newValue: Blank oldValue: Blank oprid: vmannebo recordName: RQ_DEFECT timpestamp: 2015-09-08 09:05:07.0 action: updated fieldName: Owner newValue: mchandna oldValue: rukumar oprid: vmannebo recordName: RQ_DEFECT timpestamp: 2015-09-08 09:05:07.0 action: updated fieldName: Fix By Milestone newValue: Alpha oldValue: Beta oprid: vmannebo recordName: RQ_DEFECT timpestamp: 2015-09-08 09:05:07.0 action: updated fieldName: Fix By Product Milestone newValue: Alpha oldValue: Beta oprid: vmannebo recordName: RQ_DEFECT timpestamp: 2015-09-08 09:05:07.0 action: added fieldName: Vote Type newValue: BETA oldValue: Blank oprid: prerelease recordName: AD_DEFECT_VOTE timpestamp: 2015-08-11 10:51:35.0 action: added fieldName: Vote Type newValue: BETA oldValue: Blank oprid: prerelease recordName: AD_DEFECT_VOTE timpestamp: 2015-07-29 08:32:39.0 action: updated fieldName: Owner newValue: rukumar oldValue: inoel oprid: suchsing recordName: RQ_DEFECT timpestamp: 2015-07-23 14:04:00.0 action: updated fieldName: Reason newValue: Blank oldValue: Blank oprid: suchsing recordName: RQ_DEFECT timpestamp: 2015-07-23 14:04:00.0 action: updated fieldName: Status newValue: NeedsReview oldValue: Unverified oprid: suchsing recordName: RQ_DEFECT timpestamp: 2015-07-23 14:04:00.0 action: updated fieldName: Dev Assigned newValue: mchandna oldValue: awdhesh oprid: suchsing recordName: RQ_DEFECT timpestamp: 2015-07-23 14:04:00.0 action: updated fieldName: QE Assigned newValue: suchsing oldValue: inoel oprid: suchsing recordName: RQ_DEFECT timpestamp: 2015-07-23 14:04:00.0 action: updated fieldName: Fix By Milestone newValue: Beta oldValue: Blank oprid: suchsing recordName: RQ_DEFECT timpestamp: 2015-07-23 14:04:00.0 action: updated fieldName: Fix By Product Milestone newValue: Beta oldValue: Blank oprid: suchsing recordName: RQ_DEFECT timpestamp: 2015-07-23 14:04:00.0 action: added fieldName: Vote Type newValue: BETA oldValue: Blank oprid: prerelease recordName: AD_DEFECT_VOTE timpestamp: 2015-07-22 14:57:05.0 action: added fieldName: Vote Type newValue: BETA oldValue: Blank oprid: prerelease recordName: AD_DEFECT_VOTE timpestamp: 2015-07-21 13:21:53.0 action: added fieldName: Vote Type newValue: BETA oldValue: Blank oprid: prerelease recordName: AD_DEFECT_VOTE timpestamp: 2015-07-21 09:19:35.0 action: added fieldName: Vote Type newValue: BETA oldValue: Blank oprid: prerelease recordName: AD_DEFECT_VOTE timpestamp: 2015-07-21 06:29:27.0
Comment by CFwatson U.
3520 | March 09, 2016 04:36:49 AM GMT
Please explain how this bug or feature impacts your productivity and why you are adding your vote
Vote by External U.
3522 | March 09, 2016 04:36:50 AM GMT
+1 - Users will expect str?["key"] to work
Vote by External U.
3523 | March 09, 2016 04:36:51 AM GMT
For the sake of a complete tag, I agree this is essential. I have current implementations that could really use this!
Vote by External U.
3524 | March 09, 2016 04:36:53 AM GMT
This would be a useful addition to ?. notation
Vote by External U.
3525 | March 09, 2016 04:36:54 AM GMT
voted.......................................................
Vote by External U.
3526 | March 09, 2016 04:36:55 AM GMT
Adding ?[..] seems like a natural extension of this "safe navigation" idea and should be considered.
Vote by External U.
3527 | March 09, 2016 04:36:58 AM GMT
Added By:mchandna Note Added: We have decided not to support array notation with safe navigation. Date Added :2015-10-01 13:59:44.0 Added By: PreRelease User User Name:Adam Cameron Note Added: Yeah, I'd say that if you have ?., you kinda need to have ?[ too. Date Added :2015-07-21 05:47:40.0 Added By: PreRelease User User Name:Nicholas Tunney Note Added: Entered Feature. Date Added :2015-07-21 03:17:42.0
Comment by CFwatson U.
3521 | March 09, 2016 04:37:00 AM GMT
Hi Adobe, Regarding your "We have decided not to support array notation with safe navigation." response, can you please reconsider? Thanks!, -Aaron
Comment by Aaron N.
30059 | December 16, 2018 12:27:43 AM GMT
+1 - Users will expect str?["key"] to work ..re-quoting myself
Vote by Aaron N.
30060 | December 16, 2018 12:28:47 AM GMT
Hi Adobe, I would also like to add my request to reconsider and add support for safe navigation on structs using array notation. It's all very well to have safe navigation except of course when the variable doesnt follow naming conventions... The Slack "cfml-general" channel shows there is also community support behind this request.
Comment by Benjamin R.
33161 | February 19, 2020 11:53:18 PM GMT
Please see the ECMAScript optional chaining operator to see how this operator should really work. https://cffiddle.org/app/file?filepath=d3b2138e-6954-4584-b2ef-b22b9b82d3e3/069abc33-c86c-4fdb-b36c-d10c7d6b96f1/14748a50-b6d1-40cb-83bf-c217213bf8b5.cfm <cfscript> foo = { "bar": "baz" }; writeOutput("1 `" & foo?.bar & "`<br>"); // Correct writeOutput("2 `" & food?.bar & "`<br>"); // Correct writeOutput("3 `" & foo?.baz & "`<br>"); // Not sure. I would expect that only foo would be checked but perhaps it makes sense that the entire chain would treat undefined differently. writeOutput("4 `" & foo?.bar?.len() & "`<br>"); // Correct writeOutput("5 `" & foo?.baz?.len() & "`<br>"); // Correct // writeOutput("6 `" & foo?.baz?.len?.() & "`<br>"); // Incorrect. This should check if len exists before invoking. // writeOutput("7 `" & foo?.["baz"]?.len() & "`<br>"); // Incorrect. This should work with dynamic property access. </cfscript>
Comment by Kama S.
33171 | February 21, 2020 07:22:58 PM GMT