Kotlin/kotlin-interactive-shell

NPE when typing anything in `if` block

krzema12 opened this issue · 2 comments

I just played with the tool and after typing:

if (true) 1

I got

java.lang.NullPointerException
        at org.jetbrains.kotlinx.ki.shell.parser.KotlinParserListenerForHighlighting.exitIfExpression(KotlinParserListenerForHighlighting.kt:679)
        at org.jetbrains.kotlinx.ki.shell.parser.KotlinParser$IfExpressionContext.exitRule(KotlinParser.java:13491)
        at org.antlr.v4.runtime.Parser.triggerExitRuleEvent(Parser.java:408)
        at org.antlr.v4.runtime.Parser.exitRule(Parser.java:642)
        at org.jetbrains.kotlinx.ki.shell.parser.KotlinParser.script(KotlinParser.java:514)
        at org.jetbrains.kotlinx.ki.shell.plugins.KotlinHighlighter.buildHighlighting(KotlinHighlighter.kt:39)
        at org.jetbrains.kotlinx.ki.shell.plugins.KotlinHighlighter.highlight(KotlinHighlighter.kt:20)
        at org.jetbrains.kotlinx.ki.shell.plugins.BaseHighlighter$DefaultImpls.highlight$default(BaseHighlighter.kt:8)
        at org.jetbrains.kotlinx.ki.shell.plugins.BaseHighlighter$DefaultImpls.highlight(BaseHighlighter.kt:11)
        at org.jetbrains.kotlinx.ki.shell.plugins.KotlinHighlighter.highlight(KotlinHighlighter.kt:13)
        at org.jetbrains.kotlinx.ki.shell.ContextHighlighter.highlight(ContextHighlighter.kt:16)
        at org.jline.reader.impl.LineReaderImpl.getHighlightedBuffer(LineReaderImpl.java:4041)
        at org.jline.reader.impl.LineReaderImpl.getDisplayedBufferWithPrompts(LineReaderImpl.java:3980)
        at org.jline.reader.impl.LineReaderImpl.redisplay(LineReaderImpl.java:3848)
        at org.jline.reader.impl.LineReaderImpl.redisplay(LineReaderImpl.java:3784)
        at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:708)
        at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:468)
        at org.jetbrains.kotlinx.ki.shell.Shell.doRun(Shell.kt:205)
        at org.jetbrains.kotlinx.ki.shell.KotlinShell.main(KotlinShell.kt:52)

I tried with other stuff immediately after the closing bracket after the condition and this behavior reproduces.

Could you try in 0.5.1 version, please? Should be fixed

Yep, works. Thanks!