slint-ui/slint · error
Second argument not an integer
Error message
Second argument not an integer: {:?} What it means
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.
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
Example fix
// before (.slint) property<string> selected-id; ArrayRemove(items, selected-id); // panics // after property<int> selected-index; ArrayRemove(items, selected-index);
Defensive patterns
Strategy: type-guard
Validate before calling
// .slint: declare the index as an int property property<int> selected-index; // ArrayRemove(items, selected-index) is valid
Type guard
// .slint has no runtime narrowing; enforce statically by typing the index property as int
Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- First argument not an array
- Cannot create component instance
- Cannot show component
- expect Boolean, got
- expect Number, got
AI-assisted analysis of slint-ui/slint@3a7e700487 (2026-09-16).
Data as JSON: /api/errors/27a26f08e46b5173.
Report an issue: GitHub.
Appendix: source
Thrown at internal/interpreter/eval.rs:2197
"push",
log_message_location(source_location),
model.push_row(value),
);
Value::Void
}
BuiltinFunction::ArrayRemove => {
if arguments.len() != 2 {
panic!("internal error: incorrect argument count to ArrayRemove")
}
let model = match eval_expression(ctx, &arguments[0]) {
Value::Model(m) => m,
_ => panic!("First argument not an array: {:?}", arguments[0]),
};
let index = match eval_expression(ctx, &arguments[1]) {
Value::Number(i) => i,
_ => panic!("Second argument not an integer: {:?}", arguments[1]),
};
let result = match usize::try_from(index as i64) {
Ok(index) => model.remove_row(index),
Err(_) => Err(i_slint_core::model::ModelError::out_of_bounds(model.row_count())),
};
i_slint_core::model::report_model_error(
"remove",
log_message_location(source_location),
result,
);
Value::Void
}
BuiltinFunction::ArrayInsert => {
if arguments.len() != 3 {
panic!("internal error: incorrect argument count to ArrayInsert")View on GitHub (pinned to 3a7e700487)