Skip to content

Instantly share code, notes, and snippets.

@brianmfear
Created October 28, 2020 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianmfear/2ef82800d53ed5cc40e5c920df245061 to your computer and use it in GitHub Desktop.
Save brianmfear/2ef82800d53ed5cc40e5c920df245061 to your computer and use it in GitHub Desktop.
Winter '21 Salesforce Safe Navigation Operator Bugs
// Example: CompileFail error on valid code
class B {
string field = 'Test';
}
B b1 = new B(), b2;
//System.TypeException: Comparison arguments must be compatible types: String, Boolean
System.assertEquals(true, b1.field != b2?.field);
// Example: Internal Server Error, no gack code
Contact con1, con;
System.assert(con1?.FirstName == con2?.FirstName);
// Example: debug outputs opposite value
class A {
string field = 'Test';
}
A a1 = new A(), a2;
System.debug(a1.field != a2?.field); // Outputs false, should be true
System.debug(a1.field == a2?.field); // Outputs true, should be false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment