graalvm / simplelanguage

A simple example language built using the Truffle API.

Home Page:http://openjdk.java.net/projects/graal/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"column out of range" when calling getSourceLocation() on SLParseError

numberpi opened this issue · comments

Calling Context.create("sl").eval(org.graalvm.polyglot.Source.create("sl", "function")); causes:

java.lang.IllegalArgumentException: column out of range
	at com.oracle.truffle.api.source.Source.createSection(Source.java:599)
	at com.oracle.truffle.sl.parser.SLParseError.getSourceLocation(SLParseError.java:67)
	at com.oracle.truffle.api.vm.PolyglotExceptionImpl.<init>(PolyglotExceptionImpl.java:105)
	at com.oracle.truffle.api.vm.PolyglotExceptionImpl.<init>(PolyglotExceptionImpl.java:80)
	at com.oracle.truffle.api.vm.PolyglotImpl.wrapGuestException(PolyglotImpl.java:259)
	at com.oracle.truffle.api.vm.PolyglotContextImpl.eval(PolyglotContextImpl.java:744)
	at org.graalvm.polyglot.Context.eval(Context.java:311)
	at com.oracle.truffle.api.source.Source.createSection(Source.java:599)
	at com.oracle.truffle.sl.parser.SLParseError.getSourceLocation(SLParseError.java:67)

in com.oracle.truffle.api.source.Source.createSection(int, int, int)

if (startColumn > getTextMap().lineLength(startLine)) {
    throw new IllegalArgumentException("column out of range");
}

because startColumn is 9 and getTextMap().lineLength(startLine) is 8

This can be reproduced very easily:

$ cat /tmp/File.sl
function main
graal/truffle$ mx sl /tmp/File.sl

This is fixed now by oracle/graal@dfa1c80
I do not seem to be able to close this issue.