Kotlin precondition check require() or check() evaluates to false.
Kotlin standard library functions `require(value)` or `check(value)` throw `IllegalArgumentException` or `IllegalStateException` when boolean condition evaluates to false.
Passing parameter values that violate validation logic inside `require(...)` precondition blocks.
1fun setDiscount(percentage: Int) {2 require(percentage in 0..100) { "Discount percentage must be between 0 and 100" }3}4 5fun main() {6 setDiscount(150) // Throws IllegalArgumentException: Discount percentage must be between 0 and 1007}1fun setDiscount(percentage: Int) {2 require(percentage in 0..100) { "Discount percentage must be between 0 and 100" }3}4 5fun main() {6 val input = 1507 // Fix: Sanitize or check boundary before calling setDiscount8 val validPercentage = input.coerceIn(0, 100)9 setDiscount(validPercentage)10 println("Applied discount: $validPercentage%")11}Simulate standard system builds to trigger compiler trace records and track memory crashes locally.
Passing `150` causes `percentage in 0..100` to evaluate to `false`, throwing `IllegalArgumentException`.