mirror of
https://github.com/enso-org/enso.git
synced 2024-12-23 04:43:26 +03:00
Avoid NPE on missing @anno name (#11224)
This commit is contained in:
parent
a23b66925d
commit
837a4d53b5
@ -24,6 +24,17 @@ public class ErrorCompilerTest extends CompilerTests {
|
||||
ir, Syntax.UnclosedTextLiteral$.MODULE$, "Unclosed text literal", 6, 28);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void brokenAnnotation() throws Exception {
|
||||
var ir = parse("""
|
||||
@anno
|
||||
fn = 10
|
||||
""");
|
||||
|
||||
assertSingleSyntaxError(
|
||||
ir, Syntax.UnexpectedExpression$.MODULE$, "Unexpected expression", 0, 13);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dotUnderscore() throws Exception {
|
||||
var ir = parse("""
|
||||
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.enso.compiler.core.ir.CallArgument;
|
||||
import org.enso.compiler.core.ir.DefinitionArgument;
|
||||
import org.enso.compiler.core.ir.Diagnostic;
|
||||
@ -42,6 +43,7 @@ import org.enso.syntax2.Token;
|
||||
import org.enso.syntax2.Tree;
|
||||
import org.enso.syntax2.Tree.Invalid;
|
||||
import org.enso.syntax2.Tree.Private;
|
||||
|
||||
import scala.Option;
|
||||
import scala.collection.immutable.LinearSeq;
|
||||
import scala.collection.immutable.List;
|
||||
@ -318,11 +320,15 @@ final class TreeToIr {
|
||||
}
|
||||
|
||||
case Tree.Annotated anno -> {
|
||||
if (anno.getArgument() == null) {
|
||||
yield join(translateSyntaxError(anno, Syntax.UnexpectedExpression$.MODULE$), appendTo);
|
||||
} else {
|
||||
var annotationArgument = translateExpression(anno.getArgument());
|
||||
var annotation = new Name.GenericAnnotation(anno.getAnnotation().codeRepr(),
|
||||
annotationArgument, getIdentifiedLocation(anno), meta());
|
||||
yield translateModuleSymbol(anno.getExpression(), join(annotation, appendTo));
|
||||
}
|
||||
}
|
||||
|
||||
case Tree.Documented doc -> {
|
||||
var comment = translateComment(doc, doc.getDocumentation());
|
||||
|
Loading…
Reference in New Issue
Block a user