Hey all, I’m trying to compile a trivial kotlin fi...
# javascript
a
Hey all, I’m trying to compile a trivial kotlin file to javascript using the kotlinc CLI and have been hitting a consistent error when using the IR compiler, however the program compiles fine using the legacy compiler. I’m using v1.8 (though have confirmed the same behaviour on the latest 1.9.21). Kotlin file:
Copy code
package kotlinjs.validators

private val NAME_REGEX = Regex("[a-zA-Z0-9-.' ]{1,26}")

fun validateName(name: String): Boolean = 
    NAME_REGEX.matches(name)
Using legacy compiler works fine:
Copy code
$ kotlinc-js -Xuse-deprecated-legacy-compiler -output validators.js Validators.kt
Using IR compiler:
Copy code
$ kotlinc-js -verbose -Xir-produce-js -Xgenerate-dts -output validators.js Validators.kt      
ERROR: Exception while analyzing expression in (3,29) in /Users/armon/src/github.com/kotlin-js/Validators.kt

Attachments:
causeThrowable
java.lang.AssertionError: Built-in class kotlin.String is not found
Any pointers would be appreciated 🙂
1
a
If you use
kotlinc
without Gradle, you should provide all the used libraries manually. There are a few links, that could help you: https://github.com/compiler-explorer/compiler-explorer/issues/4551 https://youtrack.jetbrains.com/issue/KT-49894
🙌 1
a
Very much appreciate the help, Artem! Solved my problem, thank you - googling was getting me nowhere
K 1