{"record":{"id":"42959bea33d054d1","repo":"Yalantis/uCrop","slug":"cimg-appname-math-parser-cimg-s-s-s-argum","errorCode":null,"errorMessage":"[cimg_appname_math_parser] CImg<%s>::%s: %s: Argument '%s' is a vector of size %u (should be <=4), in expression '%s'.","messagePattern":"\\[cimg_appname_math_parser\\] CImg<(.+?)>::(.+?): (.+?): Argument '(.+?)' is a vector of size %u \\(should be <=4\\), in expression '(.+?)'\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":20315,"sourceCode":"\n          case 'c' :\n            if (!std::strncmp(ss,\"c2o(\",4)) { // Coordinates to offset\n              _cimg_mp_op(\"Function 'c2o()'\");\n              if (*ss4=='#') { // Index specified\n                s0 = ss5; while (s0<se1 && (*s0!=',' || level[s0 - expr._data]!=clevel1)) ++s0;\n                p1 = compile(ss5,s0++,depth1,0,block_flags);\n                p3 = 1;\n                _cimg_mp_check_notnan_index(p1,ss5);\n                _cimg_mp_check_list();\n              } else { p1 = ~0U; s0 = ss4; p3 = 0; }\n              s1 = s0; while (s1<se1 && (*s1!=',' || level[s1 - expr._data]!=clevel1)) ++s1;\n              pos = compile(s0,s1,depth1,0,block_flags);\n              p2 = size(pos);\n              if (p2) { // Coordinates specified as a vector\n                if (p2>4) {\n                  *s1 = 0; s1 = s0;\n                  _cimg_mp_strerr;\n                  throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] \"\n                                              \"CImg<%s>::%s: %s: Argument '%s' is a vector of size %u (should be <=4), \"\n                                              \"in expression '%s'.\",\n                                              pixel_type(),_cimg_mp_calling_function,s_op,s1,p2,s0);\n                }\n                arg1 = pos + 1;\n                arg2 = p2>1?pos + 2:0;\n                arg3 = p2>2?pos + 3:0;\n                arg4 = p2>3?pos + 4:0;\n                arg5 = s1!=se1?compile(s1 + 1,se1,depth1,0,block_flags):0; // boundary conditions\n                _cimg_mp_check_type(arg5,p3 + 2,1,0);\n              } else { // Coordinates specified as scalars\n                arg1 = pos; arg2 = arg3 = arg4 = arg5 = 0;\n                if (s1<se1) {\n                  s0 = ++s1; while (s0<se1 && (*s0!=',' || level[s0 - expr._data]!=clevel1)) ++s0;\n                  arg2 = compile(s1,s0,depth1,0,block_flags);\n                  _cimg_mp_check_type(arg2,p3 + 2,1,0);\n                  if (s0<se1) {\n                    s1 = ++s0; while (s1<se1 && (*s1!=',' || level[s1 - expr._data]!=clevel1)) ++s1;","sourceCodeStart":20297,"sourceCodeEnd":20333,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L20297-L20333","documentation":"Math parser argument error: a function in the evaluated expression received a vector-valued argument where a scalar (at most 4 components) is expected — e.g. a variable or list item of size >4 was passed to an operator or function that only accepts scalars or small vectors; the message names the offending argument and the full expression.","triggerScenarios":"Calling coordinate-based functions (e.g. drawing/fill/interpolation ops in the math parser) passing a vector with 5+ elements as the coordinate argument.","commonSituations":"Passing an arbitrary data vector where coordinates were expected, forgetting that images have at most 4 dimensions (x,y,z,c).","solutions":["Pass at most 4 coordinate values (x,y,z,c)","Verify the argument expression builds the intended coordinate vector, not a data array","Split the call if more parameters are needed"],"exampleFix":"// before\nJ(x,y,z,c) = I(#0,x,y,z,c,extra);  // 5-element coord vector\n// after\nJ(x,y,z,c) = I(#0,x,y,z,c);","handlingStrategy":"validation","validationCode":"function checkCoordVectorSize(expr) {\n  // coordinate vectors passed to coordinate functions must have <=4 elements\n  const bad = [...expr.matchAll(/(I|J)\\s*\\(\\s*#?\\d+\\s*,([^)]*)\\)/g)]\n    .filter(m => m[2].split(',').length > 4);\n  return bad.length === 0;\n}\n","typeGuard":null,"tryCatchPattern":"try {\n  img.evaluate(expr);\n} catch (e) {\n  if (/vector of size .*\\(should be <=4\\)/.test(String(e))) {\n    // trim coordinate vector to x,y,z,c\n  } else throw e;\n}\n","preventionTips":["Remember images have at most 4 coordinates (x,y,z,c)","Never pass data arrays where coordinate vectors are expected","Validate generated coordinate expressions for arity"],"tags":["cimg","math-parser","coordinates","vector-size"],"backgroundTag":"argument-out-of-range","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}