{"record":{"id":"27a26f08e46b5173","repo":"slint-ui/slint","slug":"second-argument-not-an-integer","errorCode":null,"errorMessage":"Second argument not an integer: {:?}","messagePattern":"Second argument not an integer: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/interpreter/eval.rs","lineNumber":2197,"sourceCode":"                \"push\",\n                log_message_location(source_location),\n                model.push_row(value),\n            );\n\n            Value::Void\n        }\n        BuiltinFunction::ArrayRemove => {\n            if arguments.len() != 2 {\n                panic!(\"internal error: incorrect argument count to ArrayRemove\")\n            }\n\n            let model = match eval_expression(ctx, &arguments[0]) {\n                Value::Model(m) => m,\n                _ => panic!(\"First argument not an array: {:?}\", arguments[0]),\n            };\n            let index = match eval_expression(ctx, &arguments[1]) {\n                Value::Number(i) => i,\n                _ => panic!(\"Second argument not an integer: {:?}\", arguments[1]),\n            };\n\n            let result = match usize::try_from(index as i64) {\n                Ok(index) => model.remove_row(index),\n                Err(_) => Err(i_slint_core::model::ModelError::out_of_bounds(model.row_count())),\n            };\n            i_slint_core::model::report_model_error(\n                \"remove\",\n                log_message_location(source_location),\n                result,\n            );\n\n            Value::Void\n        }\n\n        BuiltinFunction::ArrayInsert => {\n            if arguments.len() != 3 {\n                panic!(\"internal error: incorrect argument count to ArrayInsert\")","sourceCodeStart":2179,"sourceCodeEnd":2215,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/internal/interpreter/eval.rs#L2179-L2215","documentation":"The interpreter's builtin ArrayRemove function requires its second argument to evaluate to a Value::Number (an integer index). If the evaluated argument is any other Value kind (string, model, struct, etc.), the interpreter panics. ArrayRemove performs no numeric coercion.","triggerScenarios":"Calling `ArrayRemove(arr, x)` where x evaluates to a non-number — e.g. passing a string that looks like a number, a boolean, or a struct field of the wrong type instead of the numeric index.","commonSituations":"Passing a property declared as `string` or `bool` as the index; using a value returned by another builtin that is not a number; implicit-coversion assumptions coming from other languages.","solutions":["Ensure the second argument is a number-typed property or expression, e.g. `property<int> idx;`","Convert explicitly at the call site so the expression type-checks as int (e.g. use a numeric property instead of a string field)","Use the LSP/compiler warnings to detect the type error in the .slint file before runtime"],"exampleFix":"// before (.slint)\nproperty<string> selected-id;\nArrayRemove(items, selected-id); // panics\n// after\nproperty<int> selected-index;\nArrayRemove(items, selected-index);","handlingStrategy":"type-guard","validationCode":"// .slint: declare the index as an int property\nproperty<int> selected-index; // ArrayRemove(items, selected-index) is valid","typeGuard":"// .slint has no runtime narrowing; enforce statically by typing the index property as int","tryCatchPattern":null,"preventionTips":["Only pass int/number-typed properties or expressions as indices to ArrayRemove","Avoid stringly-typed ids as indices; keep a parallel int index property","Let the compiler/LSP type-check call sites instead of relying on runtime behavior"],"tags":["interpreter","slint","type-mismatch","builtin-function"],"backgroundTag":"type-mismatch","analyzedSha":"3a7e700487dc74d404cad0726378053ab763d4e0","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}