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

WHEN_WITHOUT_ELSE doesn't recognize when expression in when branch #415

Closed
petertrr opened this issue Oct 16, 2020 · 1 comment · Fixed by #450
Closed

WHEN_WITHOUT_ELSE doesn't recognize when expression in when branch #415

petertrr opened this issue Oct 16, 2020 · 1 comment · Fixed by #450
Assignees
Labels
bug Something isn't working

Comments

@petertrr
Copy link
Member

petertrr commented Oct 16, 2020

Describe the bug

when (expr1) {
    is Type1 -> when (expr1.field) {
                is Type2 -> when (foo(epxr1)) {
                    SomeEnum.Field1 -> bar()
                    SomeEnum.Field2 -> baz()
                }
}

the when in is Type2 is not treated as an expression (it's treated as a statement, though it's an expression).

Expected behavior

WHEN_WITHOUT_ELSE shouldn't check when expressions at all until we have type resolution.

Environment information

  • diktat version: 0.1.2
@petertrr petertrr added the bug Something isn't working label Oct 16, 2020
@petertrr
Copy link
Member Author

petertrr commented Oct 16, 2020

Another false-positive: when expression is assigned to a var:

var x: Int
x = when () ...

@petertrr petertrr assigned aktsay6 and petertrr and unassigned aktsay6 Oct 22, 2020
petertrr added a commit that referenced this issue Oct 23, 2020
### What's done:
* Fixes
petertrr added a commit that referenced this issue Nov 13, 2020
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
2 participants