-
Notifications
You must be signed in to change notification settings - Fork 503
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
SystemHelper.kt:1:1: Internal Error (no-unused-imports) #1040
Comments
Without
Manually corrected, no more issues. I'm unsure why it couldn't autocorrect 1:1 |
Error stacktrace: [DEBUG] Internal Error (no-unused-imports)
com.pinterest.ktlint.core.RuleExecutionException: java.lang.IllegalStateException: No operation node for DOT_QUALIFIED_EXPRESSION. Children: [CALL_EXPRESSION]
at com.pinterest.ktlint.core.KtLint$format$2.invoke(KtLint.kt:346)
at com.pinterest.ktlint.core.KtLint$format$2.invoke(KtLint.kt:27)
at com.pinterest.ktlint.core.KtLint$visitor$2$1.invoke(KtLint.kt:241)
at com.pinterest.ktlint.core.KtLint$visitor$2$1.invoke(KtLint.kt:27)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:225)
at com.pinterest.ktlint.core.KtLint$visitor$2.invoke(KtLint.kt:239)
at com.pinterest.ktlint.core.KtLint$visitor$2.invoke(KtLint.kt:27)
at com.pinterest.ktlint.core.KtLint.format(KtLint.kt:326)
at com.pinterest.ktlint.internal.FileUtilsKt.formatFile(FileUtils.kt:99)
at com.pinterest.ktlint.KtlintCommandLine.process(Main.kt:358)
at com.pinterest.ktlint.KtlintCommandLine.access$process(Main.kt:124)
at com.pinterest.ktlint.KtlintCommandLine$lintFiles$2$1.call(Main.kt:281)
at com.pinterest.ktlint.KtlintCommandLine$lintFiles$2$1.call(Main.kt:124)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: No operation node for DOT_QUALIFIED_EXPRESSION. Children: [CALL_EXPRESSION]
at org.jetbrains.kotlin.psi.KtQualifiedExpression$DefaultImpls.getOperationTokenNode(KtQualifiedExpression.kt:35)
at org.jetbrains.kotlin.psi.KtDotQualifiedExpression.getOperationTokenNode(KtDotQualifiedExpression.kt:26)
at org.jetbrains.kotlin.psi.KtQualifiedExpression$DefaultImpls.getExpression(KtQualifiedExpression.kt:43)
at org.jetbrains.kotlin.psi.KtQualifiedExpression$DefaultImpls.getSelectorExpression(KtQualifiedExpression.kt:32)
at org.jetbrains.kotlin.psi.KtDotQualifiedExpression.getSelectorExpression(KtDotQualifiedExpression.kt:56)
at com.pinterest.ktlint.ruleset.standard.NoUnusedImportsRule.parentDotQualifiedExpression(NoUnusedImportsRule.kt:177)
at com.pinterest.ktlint.ruleset.standard.NoUnusedImportsRule.access$parentDotQualifiedExpression(NoUnusedImportsRule.kt:23)
at com.pinterest.ktlint.ruleset.standard.NoUnusedImportsRule$visit$1.invoke(NoUnusedImportsRule.kt:100)
at com.pinterest.ktlint.ruleset.standard.NoUnusedImportsRule$visit$1.invoke(NoUnusedImportsRule.kt:23)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:225)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
at com.pinterest.ktlint.ruleset.standard.NoUnusedImportsRule.visit(NoUnusedImportsRule.kt:87)
at com.pinterest.ktlint.core.KtLint$format$2.invoke(KtLint.kt:333)
... 16 more
/tmp/SystemHelper.kt:1:1: Internal Error (no-unused-imports). Please create a ticket at https://github.com/pinterest/ktlint/issues (if possible, provide the source code that triggered an error) (cannot be auto-corrected) |
Issue is not related to the outdated Kotlin version. Still fails for me with Ktlint assembled with Kotlin 1.4.30-M1 Kotlin version. |
@Tapchicoma have you tried this on master? I thought it was fixed in 3591e61 |
@romtsn yes, I've tried it on |
Test code to reproduce in master (780d11a) @Test
fun test() {
val actual = KtLint.format(
KtLint.Params(
text = """
fun foo() = 1
fun test() {
println("${'$'}{foo().toString()}")
}
""".trimIndent(),
ruleSets = listOf(StandardRuleSetProvider().get()),
cb = { _, _ -> }
)
)
assertThat(actual).isEqualTo(
"""
fun foo() = 1
fun test() {
println("${'$'}{foo()}")
}
""".trimIndent()
)
} |
Expected Behavior
I am not given this warning.
Observed Behavior
I am given this warning.
Steps to Reproduce
My .editorconfig
Affected file: SystemHelper.kt
Run
ktlint -F "src/main/kotlin/org/kamiblue/botkt/"
Your Environment
0.39.0
ktlint -F "src/main/kotlin/org/kamiblue/botkt/"
6.7.1
Linux strawberry 5.9.11-arch2-1 #1 SMP PREEMPT Sat, 28 Nov 2020 02:07:22 +0000 x86_64 GNU/Linux
The text was updated successfully, but these errors were encountered: