I have encountered a possible BUG in js, see in b...
# javascript
s
I have encountered a possible BUG in js, see in below Screenshot , while executing a Test on js side in KMP Lib, it report an error of
substring on undefined
while at compile time it is a String . However when I add a redundant
as String
Cast the error disappears! Any IDEA what could be the issue? Anyway I reported the error to youtrack to here: https://youtrack.jetbrains.com/issue/KT-46157
t
Which names do you use for tests?
s
@turansky see in screenshot below, But How does It Matter?
t
I mean
name
parameter, which produce such errors
s
@turansky I quite dont follow, can you share an example of what you are asking? Anyway you can check the whole project here if you want to https://github.com/Shabinder/youtube-api-dl
I also Found that these tests are only failing in Legacy mode but do pass in IR Mode!
t
@Shabinder Singh please be polite, sorry but I find you coc*y here.
s
I am sorry if I came as coc**y , I never intended to.😶 Edit: I used Exclamation to put down emphasis there , never wanted to be rude to anyone. After all I am asking for help, What could i gain by being rude…
👍 3
@turansky I guess I found the name parameter you wanted:
t
only failing in Legacy mode but do pass in IR Mode
Do you use
String
file level constants?
s
I believe I dont
t
Looks like you prevent DCE error with
as String
s
DCE?
s
Ohh , so legacy compiler has some limitations or DCE in Legacy mode does? As IR mode works fine. Is there a way to make legacy mode work until 1.5 Kotlin releases as in 1.4.** have some issues with IR mode like stack overlflow while building etc
t
There are known DCE errors, which produce
undefined
strings
s
there is no workaround for that?
t
Could you check
name
in
init
block?
Copy code
init {
    println(name)
}
Also question, why you couldn’t calculate
id
?
Copy code
val id = name.substring(1).toInt()
@Shabinder Singh?
s
I just dropped the idea of Using JS Legacy and will use IR as soon as Kotlin 1.5 launches .
👍 1