Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong IncorrectNumberOfArgumentsInExpression in match-expression #2283

Open
Copatych opened this issue Feb 21, 2024 · 2 comments
Open

Wrong IncorrectNumberOfArgumentsInExpression in match-expression #2283

Copatych opened this issue Feb 21, 2024 · 2 comments
Labels
bug 🪲 Something isn't working

Comments

@Copatych
Copy link

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

example code https://github.com/Copatych/MapboxBugs/blob/IncorrectNumberOfArgumentsInExpression_bug/app/src/main/java/com/example/mapboxbugs/MainActivity.kt

@Copatych Copatych added the bug 🪲 Something isn't working label Feb 21, 2024
mapbox-github-ci-writer-public-1 bot pushed a commit that referenced this issue Feb 29, 2024
Co-authored-by: root <root@a8a9f022160e>
@Krzysztof-Daniluk
Copy link

Same here

@iolandarosavoid
Copy link

I see the same warning in my code related with stop expressions, match expressions.... But anything is wrong.

I am currently using Mapbox version 11.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants