From 3e64278624ccf3e969c89058bca477cd08371193 Mon Sep 17 00:00:00 2001 From: Boolean-True Date: Tue, 14 May 2024 23:03:34 +0200 Subject: [PATCH] Fix args null in New --- src/main/java/de/maishai/ExpressionGenerator.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/maishai/ExpressionGenerator.java b/src/main/java/de/maishai/ExpressionGenerator.java index d5d87cb..3701aec 100644 --- a/src/main/java/de/maishai/ExpressionGenerator.java +++ b/src/main/java/de/maishai/ExpressionGenerator.java @@ -106,9 +106,11 @@ public class ExpressionGenerator extends DecafBaseVisitor { public Expression visitNew(DecafParser.NewContext ctx) { Type type = ASTGenerator.getType(ctx.type()); List args = new ArrayList<>(); - for (var expr : ctx.args().expr()) { - Expression astExpr = expr.accept(this); - args.add(astExpr); + if (ctx.args() != null) { + for (var expr : ctx.args().expr()) { + Expression astExpr = expr.accept(this); + args.add(astExpr); + } } return new New(type, args); }