mapbox / mapbox/mapbox-maps-ios
Handling Expression empty arrays
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 601
- Forks
- 196
- PR merge metrics
- No merged PRs in 30d
Description
## Environment
- Xcode version: 14.3.1
- Maps SDK Version: 10.15.0
## Observed behavior and steps to reproduce
It has always been a nightmare to manage match expressions with arrays, which could be empty (which leads to a crash with an error "**Expected at least one branch label**").
Now, when there's a "type safe"`Exp`, it became even harder (while overall `Exp` has much better usage), since there's no instrument to create `Exp` dynamically in any means. E.g. allowing closures inside it:
Error: Trailing closure passed to parameter of type '[Expression.Argument]' that does not accept a closure
```
let expression = Exp(.match) {
Exp(.get) { "objectId" }
if !yellowObjectIds.isEmpty {
yellowObjectIds
UIColor.yellow
}
blueObjectIds
UIColor.blue
UIColor.white
}
```
## Expected behavior
Ideally, it would be useful to cover such cases inside wrapped `Exp`, so there would be no struggle. Or at least have any instrument of dynamic creation of `Exp`
## Notes / preliminary analysis
Maybe there are already some instruments to cover my case, which I couldn't find in documentation. I would be very grateful, if somebody points me in the right direction.
## Additional links and references
I found an [old issue](https://github.com/mapbox/mapbox-gl-js/issues/7895) in js repo about the same problem, but before `Exp` were introduces
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no source file or test; begin with the type-safe Exp(.match) API and reproduce the empty-array case on Xcode 14.3.1 with Maps SDK 10.15.0. Done would require an agreed supported way to represent empty or dynamically built match branches, plus coverage or documentation for that behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, swift
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100