Check that a parameter name of a function definition does not shadow an enum definition.
This commit is contained in:
@@ -77,4 +77,19 @@ public class FunctionDefinitionTest {
|
||||
var e = assertThrows(RuntimeException.class, () -> ctxAnal.visit(tree));
|
||||
assertEquals("Error in line 1:20 Function foo has to return something of type int.", e.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldThrowExceptionIfParameterNameMatchesEnumName() {
|
||||
// given
|
||||
var tree = Helper.prepareParser("enum Bar { A, B } function foo(Bar: int): int { return 1; } foo(1);");
|
||||
var ctxAnal = new ContextAnalysis(
|
||||
Helper.getFuncs(tree),
|
||||
Helper.getStructs(tree),
|
||||
Helper.getEnums(tree)
|
||||
);
|
||||
|
||||
// when / then
|
||||
var e = assertThrows(RuntimeException.class, () -> ctxAnal.visit(tree));
|
||||
assertEquals("Error in line 1:31 Parameter name Bar duplicates an enum of the same name.", e.getMessage());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user