Browse Source

Fixed NPE if a return statement without expression was used

kindlich 5 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
 	@Override
190
 	@Override
191
 	public Boolean visitReturn(ReturnStatement statement) {
191
 	public Boolean visitReturn(ReturnStatement statement) {
192
     	javaWriter.position(statement.position.fromLine);
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
 		return true;
200
 		return true;
196
 	}
201
 	}
197
 
202
 

Loading…
Cancel
Save