Closed emeryberger closed 1 year ago
Could you send the entire testme.kt
file so I can reproduce please?
Found the bug, fix incoming.
Fixed, getting this on my machine:
% kotlinc testme.kt |& cwhy --show-prompt
===================== Prompt =====================
This is my code:
File `testme.kt`:
10 // number of digits calculation 11 while (originalNumber != 0) 12 originalNumber /= 10 13 ++digits 14 } 15 16 originalNumber = number 17 18 // result contains sum of nth power of its digits 19 while (originalNumber != 0) { 20 val remainder = originalNumber % 10 21 result += Math.pow(remainder.toDouble(), digits.toDouble()).toInt() 22 originalNumber /= 10 23 } 24 25 if (result == number) 26 print("$number ") 27 } 28 }
This is my error:
testme.kt:28:1: error: expecting a top level declaration } ^ testme.kt:16:9: error: unresolved reference: originalNumber originalNumber = number ^ testme.kt:16:26: error: unresolved reference: number originalNumber = number ^ testme.kt:19:16: error: unresolved reference: originalNumber while (originalNumber != 0) { ^ testme.kt:20:29: error: unresolved reference: originalNumber val remainder = originalNumber % 10 ^ testme.kt:21:13: error: unresolved reference: result result += Math.pow(remainder.toDouble(), digits.toDouble()).toInt() ^ testme.kt:21:20: error: unresolved reference: += result += Math.pow(remainder.toDouble(), digits.toDouble()).toInt()
[...]
^
testme.kt:21:54: error: unresolved reference: digits result += Math.pow(remainder.toDouble(), digits.toDouble()).toInt() ^ testme.kt:22:13: error: unresolved reference: originalNumber originalNumber /= 10 ^ testme.kt:22:28: error: unresolved reference: /= originalNumber /= 10 ^ testme.kt:25:13: error: unresolved reference: result if (result == number) ^ testme.kt:25:23: error: unresolved reference: number if (result == number) ^ testme.kt:26:21: error: unresolved reference: number print("$number ") ^
What's the problem?
==================================================
This happens when compiling the Kotlin test (
tests/kotlin/testme.kt
). Unfortunately, it confuses the AI, which thinks the two blocks are intentionally separate and correspond to two files.