Browse Source

Fixed NPE if a return statement without expression was used

kindlich 4 years ago
parent
commit
659dd13020
No known key found for this signature in database

+ 7
- 2
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaStatementVisitor.java View File

@@ -190,8 +190,13 @@ public class JavaStatementVisitor implements StatementVisitor<Boolean> {
190 190
 	@Override
191 191
 	public Boolean visitReturn(ReturnStatement statement) {
192 192
     	javaWriter.position(statement.position.fromLine);
193
-		statement.value.accept(expressionVisitor);
194
-		javaWriter.returnType(context.getType(statement.value.type));
193
+    	if(statement.value == null) {
194
+    		javaWriter.ret();
195
+		} else {
196
+			statement.value.accept(expressionVisitor);
197
+			javaWriter.returnType(context.getType(statement.value.type));
198
+		}
199
+
195 200
 		return true;
196 201
 	}
197 202
 

Loading…
Cancel
Save