浏览代码

Fixed NPE if a return statement without expression was used

kindlich 4 年前
父节点
当前提交
659dd13020
找不到此签名对应的密钥

+ 7
- 2
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaStatementVisitor.java 查看文件

@@ -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
 

正在加载...
取消
保存