How to use -script option?


#1

Hi,

I see the compiler has an -script option. Is that allow you to evaluate a source file on the fly?

Trying the obvious would give error:

``

bin/kotlinc-jvm -script -src Test.kt
Exception in thread “main” java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
     at java.util.ArrayList.rangeCheck(ArrayList.java:604)
     at java.util.ArrayList.get(ArrayList.java:382)
     at org.jetbrains.jet.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.java:81)
     at org.jetbrains.jet.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.java:54)
     at org.jetbrains.jet.cli.common.CLICompiler.exec(CLICompiler.java:117)
     at org.jetbrains.jet.cli.jvm.K2JVMCompiler.exec(K2JVMCompiler.java:182)
     at org.jetbrains.jet.cli.jvm.K2JVMCompiler.exec(K2JVMCompiler.java:54)
     at org.jetbrains.jet.cli.common.CLICompiler.exec(CLICompiler.java:47)
     at org.jetbrains.jet.cli.common.CLICompiler.doMainNoExit(CLICompiler.java:160)
     at org.jetbrains.jet.cli.common.CLICompiler.doMain(CLICompiler.java:151)
     at org.jetbrains.jet.cli.jvm.K2JVMCompiler.main(K2JVMCompiler.java:58)

So how do I use the -script option?

Thanks,
Zemian


#2

This is clearly a bug. Please report to the tracker.

Here’s a working example as of M3:
http://blog.jetbrains.com/kotlin/2012/09/kotlin-m3-is-out/


#3

http://youtrack.jetbrains.com/issue/KT-3045