{"record":{"id":"36db3637c63a2115","repo":"Yalantis/uCrop","slug":"cimg-appname-math-parser-cimg-s-s-s-inval-36db36","errorCode":null,"errorMessage":"[cimg_appname_math_parser] CImg<%s>::%s: %s: Invalid types in specified arguments, in expression '%s'.","messagePattern":"\\[cimg_appname_math_parser\\] CImg<(.+?)>::(.+?): (.+?): Invalid types in specified arguments, in expression '(.+?)'\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":21416,"sourceCode":"                  _cimg_mp_check_type((unsigned int)opcode[10],11,1,0); // dx\n                  _cimg_mp_check_type((unsigned int)opcode[11],12,1,0); // dy\n                  _cimg_mp_check_type((unsigned int)opcode[12],13,1,0); // dz\n                  _cimg_mp_check_type((unsigned int)opcode[13],14,1,0); // dc\n                  if (opcode._height>14) _cimg_mp_check_type((unsigned int)opcode[14],15,1,0); // opac\n                  if (opcode._height>16) _cimg_mp_check_type((unsigned int)opcode[16],17,1,0); // maxM\n                  CImg<ulongT>::vector((ulongT)mp_vector_draw,\n                                       *opcode,size((unsigned int)*opcode), // 1-2: D,sizD\n                                       opcode[1],opcode[2],opcode[3],opcode[4], // 3-6: w,h,d,s\n                                       opcode[5],size((unsigned int)opcode[5]), // 7-8: S,sizS\n                                       opcode[6],opcode[7],opcode[8],opcode[9], // 9-12: x,y,z,c\n                                       opcode[10],opcode[11],opcode[12],opcode[13], // 13-16: dx,dy,dz,dc\n                                       opcode._height<15?1:opcode[14], // 17: opac\n                                       opcode._height<16?~0U:opcode[15], // 18: M\n                                       opcode._height<16?0:size((unsigned int)opcode[15]), // 19: sizM\n                                       opcode._height<17?1:opcode[16]).move_to(code); // 20: maxM\n                } else {\n                  _cimg_mp_strerr;\n                  throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] \"\n                                              \"CImg<%s>::%s: %s: Invalid types in specified arguments, \"\n                                              \"in expression '%s'.\",\n                                              pixel_type(),_cimg_mp_calling_function,s_op,s0);\n                }\n\n              } else { // Drawing in an image\n                if (!is_inside_critical) is_parallelizable = false;\n                arg1 = p1!=~0U;\n                _cimg_mp_check_type((unsigned int)*opcode,1 + arg1,2,0); // S\n                if (opcode._height<3 || (opcode._height<5 && is_vector((unsigned int)opcode[2]))) {\n                  // S[,opac,M,maxM].\n                  if (opcode._height>1) _cimg_mp_check_type((unsigned int)opcode[1],2 + arg1,1,0); // opac\n                  if (opcode._height>3) _cimg_mp_check_type((unsigned int)opcode[3],4 + arg1,1,0); // maxM\n                  CImg<ulongT>::vector((ulongT)mp_image_draw,\n                                       *opcode,size((unsigned int)*opcode),p1, // 1-3: S,sizS,#ind\n                                       0,0,0,0, // 4-7: x,y,z,c\n                                       ~0U,~0U,~0U,~0U, // 8-11: dx,dy,dz,dc\n                                       opcode._height<2?1:opcode[1], // 12: opac","sourceCodeStart":21398,"sourceCodeEnd":21434,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L21398-L21434","documentation":"A type-validation failure in the vector-drawing branch of a drawing opcode (the branch handling drawing into a vector with the 17-slot layout: coords, color, opacity, mask M, maxM). After generating code for the accepted argument types, the parser's final `else` fires when the supplied arguments don't match any supported type combination — e.g. a coordinate argument that is neither a scalar nor a proper vector. It reports 'Invalid types in specified arguments' rather than a count problem.","triggerScenarios":"Calling the vector draw function where required arguments have wrong expression types: e.g. passing a non-vector where a color/mask vector is expected, a vector where a scalar coordinate is required, or omitting arguments in a way that makes positionally-read types wrong (color read as coordinate, etc.).","commonSituations":"Swapping two arguments (opacity before color); passing an image variable where a vector variable is expected; relying on defaults but with the wrong types in early positions shifting everything; expressions ported from the image-draw variant.","solutions":["Ensure each argument has the type the slot expects: scalars for coordinates/opacity, vectors for color and mask M.","Check the arguments positionally against the 17-slot layout (coords..., color vector, opac, M, maxM).","Use `_cimg_mp`-documented type checks mentally: is_vector()/is_scalar() on the failing argument.","Split the call and assign intermediate named variables so types are explicit."],"exampleFix":"// before\ndraw(V, x, y, 255) // scalar where color vector expected -> invalid types\n// after\ncolor = [255,255,255]; draw(V, x, y, color, 255);","handlingStrategy":"type-guard","validationCode":"// verify vector-typed slots before evaluating\nif (!color.is_vector()) throw std::runtime_error(\"color argument must be a vector\");\nif (!std::isfinite(opac)) throw std::runtime_error(\"opacity must be a scalar\");","typeGuard":"bool args_well_typed(const CImg<float>& color, float opac, const CImg<float>* mask) {\n  return color.is_vector() && std::isfinite(opac) && (!mask || mask->is_vector());\n}","tryCatchPattern":"try {\n  img.fill(expr.c_str());\n} catch (const CImgArgumentException& e) {\n  // invalid draw argument types: log expression and skip drawing\n}","preventionTips":["Keep argument order fixed: coordinates, color vector, opacity, mask","Never pass an image where a vector variable is expected","Assign intermediate named variables so argument types are explicit","Test draw calls with literal constants before using dynamic values"],"tags":["cimg","math-parser","draw","type-mismatch"],"backgroundTag":"type-mismatch","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"}