{"record":{"id":"369dd9df56d04f4c","repo":"Yalantis/uCrop","slug":"cimg-appname-math-parser-cimg-s-s-s-s-na","errorCode":null,"errorMessage":"[cimg_appname_math_parser] CImg<%s>::%s: %s: %s name specified for argument %u when defining macro '%s()', in expression '%s'.","messagePattern":"\\[cimg_appname_math_parser\\] CImg<(.+?)>::(.+?): (.+?): (.+?) name specified for argument %u when defining macro '(.+?)\\(\\)', in expression '(.+?)'\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":18608,"sourceCode":"                                                pixel_type(),_cimg_mp_calling_function,s_op,\n                                                variable_name._data,s0);\n                  }\n                  while (*s && cimg::is_blank(*s)) ++s;\n                  if (*s==')' && p1==1) break; // Function has no arguments\n                  s2 = s; // Start of the argument name\n                  is_sth = true; // is_valid_argument_name?\n                  if (*s2>='0' && *s2<='9') is_sth = false;\n                  else for (ns = s2; ns<s1 && *ns!=',' && *ns!='.' && !cimg::is_blank(*ns); ++ns)\n                         if (!cimg::is_varchar(*ns)) { is_sth = false; break; }\n                  s3 = ns; // End of the argument name\n                  if (is_sth && ns>s2 && *ns=='.' && ns[1]=='.' && ns[2]=='.') { is_variadic = true; ns+=3; }\n                  else if (*ns=='.') is_sth = false;\n                  while (*ns && cimg::is_blank(*ns)) ++ns;\n\n                  if (!is_sth || s2==s3 || (*ns!=',' && ns!=s1)) {\n                    cimg::strellipsize(variable_name,64);\n                    _cimg_mp_strerr;\n                    throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] \"\n                                                \"CImg<%s>::%s: %s: %s name specified for argument %u when defining \"\n                                                \"macro '%s()', in expression '%s'.\",\n                                                pixel_type(),_cimg_mp_calling_function,s_op,\n                                                is_sth?\"Empty\":\"Invalid\",p1,\n                                                variable_name._data,s0);\n                  }\n\n                  if (ns==s1 || *ns==',' || (is_variadic && *ns=='.')) { // New argument found\n                    *s3 = 0;\n                    p2 = (unsigned int)(s3 - s2); // Argument length\n                    for (ps = std::strstr(macro_body[0],s2); ps; ps = std::strstr(ps,s2)) { // Replace by arg number\n                      if (!((ps>macro_body[0]._data && cimg::is_varchar(*(ps - 1))) ||\n                            (ps + p2<macro_body[0].end() && cimg::is_varchar(*(ps + p2))))) {\n                        if (ps>macro_body[0]._data && *(ps - 1)=='#') { // Remove pre-number sign\n                          *(ps - 1) = (char)p1;\n                          if (ps + p2<macro_body[0].end() && *(ps + p2)=='#') { // Has pre & post number signs\n                            std::memmove(ps,ps + p2 + 1,macro_body[0].end() - ps - p2 - 1);\n                            macro_body[0]._width-=p2 + 1;","sourceCodeStart":18590,"sourceCodeEnd":18626,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L18590-L18626","documentation":"When defining a macro, each argument name in the formal parameter list must be a valid, non-empty identifier. If an argument name is empty or contains invalid characters (e.g. starts with '.'), the math parser throws this error at macro-definition compile time.","triggerScenarios":"Declaring a macro like 'f(,x)=...' (empty name), 'f(x.,y)=...' or 'f(.a)=...' (invalid identifier characters) so that is_sth is false or s2==s3 or the character after the name is not ','.","commonSituations":"Typos in macro definitions, programmatic generation of macro strings with malformed parameter lists, stray separators or dots in argument names.","solutions":["Give every macro argument a valid non-empty identifier (letters/digits/underscore)","Remove stray commas, dots or whitespace artifacts from the parameter list","Print the full expression before passing it to the parser to spot the malformed definition"],"exampleFix":"// before\nmyfunc(,b) = a+b;\n// after\nmyfunc(a,b) = a+b;","handlingStrategy":"validation","validationCode":"function checkMacroParamNames(expr) {\n  const m = expr.match(/^\\s*\\w+\\s*\\(([^)]*)\\)\\s*=/);\n  if (!m) return true;\n  const ident = /^[A-Za-z_]\\w*$/;\n  return m[1].split(',').every(p => ident.test(p.trim()));\n}\n","typeGuard":null,"tryCatchPattern":"try {\n  img.evaluate(expr);\n} catch (e) {\n  if (/name specified for argument/.test(String(e))) {\n    // log expr and fix malformed parameter list\n  } else throw e;\n}\n","preventionTips":["Validate parameter identifiers with a regex before evaluation","Avoid programmatic string building of parameter lists; use templates","Trim whitespace and strip stray separators from generated definitions"],"tags":["cimg","math-parser","macro-definition","invalid-identifier"],"backgroundTag":"invalid-identifier-format","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"}