I’ve run into an issue in Lucee 5-7 which differs from ACF and seems like a bug to me related to how safe operators are working.
In the following code, I would expect the call to shouldThrowError()
to return an exception, because throwError()
will always trigger an exception. However, because of the use of the safe operator, the exception gets swallowed:
function throwError(){
throw "Oops";
return {test=true};
}
function shouldThrowError(){
return throwError()?.test;
}
writeDump(shouldThrowError());
You can view this example here:
In ACF, it’s throwing an exception like I would expect.
In looking at the Safe Navigation Operator docs, it only indicates null
values are ignored. I’d certainly expect an exception to still be thrown.
Is this an expected behavior in Lucee or is this a bug?