Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Top-level aftermarket expression functions fail to parse #271

Open
@1ec5

Description

As of iOS 11.4 and macOS 10.15.4, if an “aftermarket” expression function like the ones added in mapbox/mapbox-gl-native#11472 appears at the top level of an NSExpression format string, it may raise an “Unable to parse the format string” exception unless certain syntaxes are used to make it an explicit function call. For example:

  • mgl_round(3.14159) 💥
  • mgl_round:(3.14159) ✔️
  • (mgl_round(3.14159)) ✔️
  • mgl_round(3.14159) + 0 ✔️
  • abs(mgl_round(3.14159)) ✔️

This issue affects any of the functions installed by +[MGLAftermarketExpressionInstaller installFunctions]:

// Install method-like functions, taking the number of arguments implied by
// the selector name.
INSTALL_METHOD(mgl_join:);
INSTALL_METHOD(mgl_round:);
INSTALL_METHOD(mgl_interpolate:withCurveType:parameters:stops:);
INSTALL_METHOD(mgl_step:from:stops:);
INSTALL_METHOD(mgl_coalesce:);
INSTALL_METHOD(mgl_does:have:);
INSTALL_METHOD(mgl_acos:);
INSTALL_METHOD(mgl_cos:);
INSTALL_METHOD(mgl_asin:);
INSTALL_METHOD(mgl_sin:);
INSTALL_METHOD(mgl_atan:);
INSTALL_METHOD(mgl_tan:);
INSTALL_METHOD(mgl_log2:);
INSTALL_METHOD(mgl_attributed:);
// Install functions that resemble control structures, taking arbitrary
// numbers of arguments. Vararg aftermarket functions need to be declared
// with an explicit and implicit first argument.
INSTALL_CONTROL_STRUCTURE(MGL_LET);
INSTALL_CONTROL_STRUCTURE(MGL_MATCH);
INSTALL_CONTROL_STRUCTURE(MGL_IF);
INSTALL_CONTROL_STRUCTURE(MGL_FUNCTION);

I suspect this regression is caused by a change in Apple’s iOS/macOS SDK, not the Mapbox Maps SDK. It’s possible that one of these private methods is responsible for raising the error. However, there probably isn’t much we can do about this issue, because we’re trying to avoid any potential App Store submission issues that would arise from calling any private method. We’re only extending the _NSPredicateUtilities class, which we’re only obtaining indirectly using official documented APIs.

In the absence of a fix, we should document this edge case in the “Predicates and Expressions” guide.

/cc @mapbox/maps-ios

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions