{"record":{"id":"63dd82e3529f7941","repo":"Yalantis/uCrop","slug":"cimg-appname-math-parser-cimg-s-s-unrec","errorCode":null,"errorMessage":"[\" cimg_appname \"_math_parser] CImg<%s>::%s: Unrecognized %s '%s' in expression '%s'.","messagePattern":"\\[\" cimg_appname \"_math_parser\\] CImg<(.+?)>::(.+?): Unrecognized (.+?) '(.+?)' in expression '(.+?)'\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":24761,"sourceCode":"        // No known item found, assuming this is an already initialized variable.\n        if (cimg::is_varname(variable_name)) { // Valid variable name\n          get_variable_pos(variable_name,arg1,arg2);\n          arg1 = arg2!=~0U?reserved_label[arg2]:arg1!=~0U?variable_pos[arg1]:~0U;\n          if (arg1!=~0U) _cimg_mp_return(arg1);\n        }\n\n        // Reached an unknown item -> error.\n        c1 = *se1;\n        cimg::strellipsize(variable_name,64);\n        _cimg_mp_strerr;\n        if (is_sth)\n          throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] \"\n                                      \"CImg<%s>::%s: Undefined variable '%s' in expression '%s'.\",\n                                      pixel_type(),_cimg_mp_calling_function,\n                                      variable_name._data,s0);\n        s1 = std::strchr(ss,'(');\n        s_op = s1 && c1==')'?\"function call\":\"item\";\n        throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] \"\n                                    \"CImg<%s>::%s: Unrecognized %s '%s' in expression '%s'.\",\n                                    pixel_type(),_cimg_mp_calling_function,\n                                    s_op,variable_name._data,s0);\n      }\n\n      // Evaluation procedure.\n      double operator()(const double x, const double y, const double z, const double c) {\n        mem[_cimg_mp_slot_x] = x; mem[_cimg_mp_slot_y] = y; mem[_cimg_mp_slot_z] = z; mem[_cimg_mp_slot_c] = c;\n        for (p_code = code; p_code<p_code_end; ++p_code) {\n          opcode._data = p_code->_data;\n          const ulongT target = opcode[1];\n          mem[target] = _cimg_mp_defunc(*this);\n        }\n        return *result;\n      }\n\n      // Evaluation procedure (return output values in vector 'output').\n      template<typename t>","sourceCodeStart":24743,"sourceCodeEnd":24779,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L24743-L24779","documentation":"Counterpart to the 'Undefined variable' error in CImg's math parser: when the unknown token looks like an invocation (followed by '(' with a preceding ')'), it is classified as an unrecognized 'function call'; otherwise it is an unrecognized 'item'. The parser throws because it cannot resolve the token to any known function or syntactic element in the expression.","triggerScenarios":"Evaluating an expression containing a call to a function name that does not exist in the parser's function table (typo or removed/renamed builtin), or an unparseable token sequence such as stray punctuation.","commonSituations":"Calling functions from newer CImg versions on an older vendored copy (e.g. the JNI-bundled CImg.h in ucrop); typos like sqtr(x) instead of sqrt(x); locale-copied expressions with mangled characters.","solutions":["Verify the function name exists in your CImg version's math-function list; fix typos.","Update the vendored CImg.h if the expression uses functions added in a newer version.","Rewrite unsupported functions using available parser primitives/macros.","Remove or correct stray characters that make the token unparseable.","Test the expression in a small standalone CImg program before embedding it."],"exampleFix":"// before\nimg.fill(sqtr(x)); // unrecognized function call\n// after\nimg.fill(sqrt(x)); // existing parser function","handlingStrategy":"validation","validationCode":"Set<String> knownFns = Set.of(\"sin\",\"cos\",\"sqrt\",\"abs\",\"min\",\"max\"); // per your CImg version\nfor (String fn : extractCalledFunctions(expression))\n    if (!knownFns.contains(fn)) throw new IllegalArgumentException(\"unknown function: \" + fn);","typeGuard":null,"tryCatchPattern":"try {\n    img.fill(expression);\n} catch (CImgInstantiationException e) {\n    if (e.getMessage().contains(\"Unrecognized\")) {\n        // check whether 'function call' or 'item' in message, correct token\n    }\n    throw e;\n}","preventionTips":["Check function names against the math-function reference of your exact CImg version.","Keep the vendored CImg.h in sync with expressions using newer functions.","Lint generated expressions for typos and stray punctuation.","Smoke-test each expression in CI before shipping."],"tags":["cimg","math-parser","unrecognized-function","expression"],"backgroundTag":"unsupported-operation","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}