Don't NPE on op ._ when translating tree to IR (#8381)

Encountered a random NPE when playing with bookclubs. Test case demonstrating the problem is attached.

Threw in a bunch of minor tweaks to logs to make life of the person debugging code more pleasant.
This commit is contained in:
Hubert Plociniczak 2023-11-23 20:56:56 +01:00 committed by GitHub
parent 76fb9f5c4b
commit 36996c8938
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 3 deletions

View File

@ -40,6 +40,7 @@ logging-service {
org.enso.languageserver.protocol.json.JsonConnectionController = debug
org.enso.jsonrpc.JsonRpcServer = debug
org.enso.languageserver.runtime.RuntimeConnector = debug
org.enso.interpreter.runtime.HostClassLoader = error
}
appenders = [
{

View File

@ -43,6 +43,8 @@ public interface CompilerContext extends CompilerStub {
void log(Level level, String msg, Object... args);
void log(Level level, String msg, Throwable ex);
void logSerializationManager(Level level, String msg, Object... args);
void notifySerializeModule(QualifiedName moduleName);

View File

@ -26,7 +26,7 @@ class AttachVisualizationCmd(
): Future[Unit] = {
ctx.executionService.getLogger.log(
Level.FINE,
"Attach visualization cmd for request id [{}] and visualization id [{}]",
"Attach visualization cmd for request id [{0}] and visualization id [{1}]",
Array(maybeRequestId, request.visualizationId)
)
ctx.endpoint.sendToClient(

View File

@ -139,7 +139,7 @@ class UpsertVisualizationJob(
)(implicit ctx: RuntimeContext): Unit = {
ctx.executionService.getLogger.log(
Level.SEVERE,
"Visualization for expression {0} failed: {1} (evaluation result: {2}",
"Visualization for expression {0} failed: {1} (evaluation result: {2})",
Array(expressionId, message, executionResult)
)
ctx.endpoint.sendToClient(

View File

@ -1438,7 +1438,11 @@ final class TreeToIr {
} else {
throw translateEntity(app, Syntax.UnexpectedExpression$.MODULE$);
}
list = app.getLhs();
if (app.getLhs() != null) {
list = app.getLhs();
} else {
throw translateEntity(app, Syntax.UnexpectedExpression$.MODULE$);
}
}
segments.add(list);
java.util.Collections.reverse(segments);

View File

@ -93,6 +93,11 @@ final class TruffleCompilerContext implements CompilerContext {
loggerCompiler.log(level, msg, args);
}
@Override
public void log(Level level, String msg, Throwable ex) {
loggerCompiler.log(level, msg, ex);
}
@Override
public void logSerializationManager(Level level, String msg, Object... args) {
loggerSerializationManager.log(level, msg, args);

View File

@ -30,6 +30,16 @@ public class ErrorCompilerTest extends CompilerTest {
assertSingleSyntaxError(ir, Syntax.InvalidUnderscore$.MODULE$, "Invalid use of _", 14, 15);
}
@Test
public void spaceDotUnderscore() throws Exception {
var ir = parse("""
run op =
op ._
""");
assertSingleSyntaxError(ir, Syntax.UnexpectedExpression$.MODULE$, "Unexpected expression", 14, 16);
}
@Test
public void unaryMinus() throws Exception {
var ir = parse("""