alibaba / alibaba/QLExpress

当前版本是否支持字符类型与数字类型的计算?如下代码会报 java.lang.Character cannot be cast to class java.lang.Number

Open
#150 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
5.6k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

@Test
public void test() throws Exception {

System.out.println('a'<98);
ExpressRunner runner = new ExpressRunner();
String[] expList = new String[]{
" String ocr_address=\"aabbcc\";\n" +
" String busi_address=\"aabbcc\";\n" +
" if (ocr_address == null || ocr_address == \"\") {\n" +
" System.out.println(false);\n" +
" } else {\n" +
" char[] c = busi_address.toCharArray();\n" +
" for (int i = 0; i < c.length; i++) {\n" +
" if (c[i] == 12288) {\n" +
" c[i] = (char) 32;\n" +
" continue;\n" +
" }\n" +
" if (c[i] > 65280 && c[i] < 65375)\n" +
" c[i] = (char) (c[i] - 65248);\n" +
" }\n" +
" busi_address = new String(c);\n" +
" System.out.println(ocr_address.equals(busi_address));\n" +
" }"
};
IExpressContext context = new DefaultContext();
context.put("test",'a'+0);
for(String exp : expList) {
Object result = runner.execute(exp, context, null, true, false);
System.out.println(result);
assert (true == (Boolean) result);
}
}

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the provided test method and its expressions through ExpressRunner.execute, focusing on the character-to-number comparisons and the reported ClassCastException. Trace the expression evaluation path used by execute to identify where the comparison fails. Done means the supplied character and numeric comparisons execute without the reported cast error and the test assertions pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.