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

[standard:function-literal] Crash with reduntant lambda arrow #2331

Closed
lwasyl opened this issue Oct 23, 2023 · 1 comment · Fixed by #2365
Closed

[standard:function-literal] Crash with reduntant lambda arrow #2331

lwasyl opened this issue Oct 23, 2023 · 1 comment · Fixed by #2365

Comments

@lwasyl
Copy link

lwasyl commented Oct 23, 2023

Expected Behavior

ktlint should not crash

Observed Behavior

ktlint crashes

Steps to Reproduce

fun foo(block: () -> Unit): Unit = foo { -> block() }

Your Environment

  • Version of ktlint used: 1.0.1
  • Relevant parts of the .editorconfig settings: none, although function-literal seems to be crashing even with ktlint_code_style = intellij_idea, whereas the documentation states the rule runs only with kotlin_official code style
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): ktlint-gradle-plugin
  • Version of Gradle used (if applicable): 8.3
  • Operating System and version:
@paul-dingemans
Copy link
Collaborator

paul-dingemans commented Oct 23, 2023

The function-literal rule is introduced in version 1.0.0. The documentation is incorrect. The rule is an experimental rule and will only be run when the the experimental rules are enabled.

Both documentation and rule need to be fixed. Tnx for reporting.

@paul-dingemans paul-dingemans added this to the 1.1 milestone Oct 23, 2023
paul-dingemans added a commit that referenced this issue Nov 19, 2023
Kotlin allows a function literal to be defined with an empty parameter list and a redundant arrow symbol to divide the parameter list from the body.

Closes #2331
paul-dingemans added a commit that referenced this issue Nov 19, 2023
paul-dingemans added a commit that referenced this issue Nov 19, 2023
…ocumentation (#2365)

Kotlin allows a function literal to be defined with an empty parameter list and a redundant arrow symbol to divide the parameter list from the body.

Fix documentation, `function-literal` rule is experimental and not bound to `ktlint_official` code style.

Closes #2331
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants