Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

And expression that contains a function that returns a boolean always evaluates to false #2

Open
caojunliangAlex opened this issue Jul 26, 2023 · 0 comments

Comments

@caojunliangAlex
Copy link

Problem:
Assume that s is a string.
expression : s.contains("a") && s.contains("b")
The result is always false.

The "toBoolean" method of class "com.greenpineyu.fel.function.operator.And" need some improvement.

public String toBoolean(FelNode node, FelContext ctx, int index) {
	List<FelNode> children = node.getChildren();
	FelNode child = children.get(index);
	SourceBuilder method = child.toMethod(ctx);
	Class<?> type = method.returnType(ctx, child);

            //problem is here,primitive type boolean is not included.
	if (Boolean.class.isAssignableFrom(type) ||  boolean.class.isAssignableFrom(type)) {
		return "(" + method.source(ctx, child) + ")";
	}
	if (String.class.isAssignableFrom(type)) {
		return "Boolean.valueOf(" + method.source(ctx, child) + ")";
	}
	if (Null.class.isAssignableFrom(type)) {
		return "false";
	}
	return "false";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant