Skip to content

Commit 4ae9261

Browse files
authored
Merge pull request #217 from fujaba/fix/variable-redeclaration-npe
Fix NPE on variable redeclaration
2 parents b916259 + 9c57fc0 commit 4ae9261

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/main/java/org/fulib/scenarios/visitor/resolve/SentenceResolver.java

+11-4
Original file line numberDiff line numberDiff line change
@@ -510,12 +510,19 @@ else if (name.contains("++"))
510510
private void checkForExisting(Scope par, String name, Position position)
511511
{
512512
final Decl existing = par.resolve(name);
513-
if (existing != null)
513+
if (existing == null)
514514
{
515-
par.report(error(position, "variable.redeclaration", name)
516-
.note(note(position, "variable.redeclaration.hint"))
517-
.note(note(existing.getPosition(), "variable.declaration.first", name)));
515+
return;
518516
}
517+
518+
final Marker error = error(position, "variable.redeclaration", name);
519+
error.note(note(position, "variable.redeclaration.hint"));
520+
final Position existingPosition = existing.getPosition();
521+
if (existingPosition != null)
522+
{
523+
error.note(note(existingPosition, "variable.declaration.first", name));
524+
}
525+
par.report(error);
519526
}
520527

521528
private static String findUnique(String name, Scope par)

0 commit comments

Comments
 (0)