Skip to content

Commit

Permalink
Argument block application has no place in type body (#8877)
Browse files Browse the repository at this point in the history
Fixes #8832 by reporting a `SyntaxError` in `TreeToIr` conversion.
  • Loading branch information
JaroslavTulach authored Jan 28, 2024
1 parent 644c9af commit 74b808b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,10 @@ private List<IR> translateTypeBodyExpressionImpl(Tree exp, List<IR> appendTo) th
yield join(ir, appendTo);
}

case Tree.ArgumentBlockApplication app -> appendTo;
case Tree.ArgumentBlockApplication app -> {
var ir = translateSyntaxError(app, Syntax.UnexpectedDeclarationInType$.MODULE$);
yield join(ir, appendTo);
}

case Tree.TypeSignature sig -> {
var isMethod = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,21 @@ public void testNPE183863754() throws Exception {
assertEquals(errors.head().location().get().length(), 6);
}

@Test
public void testMissingEqualsInMethodDefinition() throws Exception {
var ir = parse("""
type T
method self
42
""");
assertSingleSyntaxError(
ir,
Syntax.UnexpectedDeclarationInType$.MODULE$,
"Unexpected declaration in the body of a type",
9,
27);
}

@Test
public void testAnnotation1() throws Exception {
var ir = parse("""
Expand Down

0 comments on commit 74b808b

Please sign in to comment.