Skip to content

短路问题:user != nil && user.id > book.id && (nil + 1 > 3) #695

@qiangbro

Description

@qiangbro
public static void main(String[] args) {
    boolean result = (boolean) AviatorEvaluator.execute("user != nil && user.id > book.id && (nil + 1 > 3)");
    System.out.println(result);
}

希望短路并返回false,但是抛了异常:

Exception in thread "main" com.googlecode.aviator.exception.ExpressionRuntimeException: Could not add <Nil, null> with <Long, 1>
	at com.googlecode.aviator.runtime.type.AviatorObject.add(AviatorObject.java:153)
	at com.googlecode.aviator.runtime.type.AviatorNil.add(AviatorNil.java:51)
	at com.googlecode.aviator.lexer.token.OperatorType.eval(OperatorType.java:108)
	at com.googlecode.aviator.runtime.op.OperationRuntime.eval0(OperationRuntime.java:57)
	at com.googlecode.aviator.runtime.op.OperationRuntime.eval(OperationRuntime.java:47)
	at com.googlecode.aviator.code.OptimizeCodeGenerator.executeOperator(OptimizeCodeGenerator.java:221)
	at com.googlecode.aviator.code.OptimizeCodeGenerator.execute(OptimizeCodeGenerator.java:158)
	at com.googlecode.aviator.code.OptimizeCodeGenerator.getResult(OptimizeCodeGenerator.java:361)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions