mapbox / mapbox/mapbox-maps-android
Wrong IncorrectNumberOfArgumentsInExpression in match-expression
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 578
- Forks
- 161
- PR merge metrics
- No merged PRs in 30d
Description
Environment
- Android OS version: No matter
- Devices affected: No matter
- Maps SDK Version: 11.1.0
Observed behavior and steps to reproduce
I get lint error IncorrectNumberOfArgumentsInExpression "Incorrect number of expressions within match Expression: expected an even number, but 5 was found." in this code:
enum class Type(@ColorInt val color: Int) {
RED(Color.RED),
GREEN(Color.GREEN),
BLUE(Color.BLUE);
}
fun Expression.ExpressionBuilder.getColor(type: Type) {
stop {
literal(type.name)
color(type.color)
}
}
...
// there is IncorrectNumberOfArgumentsInExpression
lineColor(
match {
get("type")
getColor(Type.RED)
getColor(Type.GREEN)
getColor(Type.BLUE)
color(Color.BLACK)
}
)
This code does not have an error:
lineColor(
match {
get("type")
stop {
literal(Type.RED.name)
color(Type.RED.color)
}
stop {
literal(Type.GREEN.name)
color(Type.GREEN.color)
}
stop {
literal(Type.BLUE.name)
color(Type.BLUE.color)
}
color(Color.BLACK)
}
)
Expected behavior
No lint error IncorrectNumberOfArgumentsInExpression
Notes / preliminary analysis
Additional links and references
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
Start with the reproduction in MainActivity.kt from the linked example, using Maps SDK 11.1.0, and run the lint checks that report IncorrectNumberOfArgumentsInExpression. Compare the helper-based match expression with the inline stop expressions; done means the reported lint error is no longer produced for the shown code.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100