{"record":{"id":"6eb0ef25faae2630","repo":"louis-e/arnis","slug":"internal-error-entered-unreachable-code","errorCode":null,"errorMessage":"internal error: entered unreachable code","messagePattern":"internal error: entered unreachable code","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/element_processing/leisure.rs","lineNumber":117,"sourceCode":"                // or path inside the park is drawn after it, so its columns still\n                // read as grass here and only the mask tells them apart.\n                if matches!(leisure_type.as_str(), \"park\" | \"garden\" | \"nature_reserve\")\n                    && editor.check_for_block(x, 0, z, Some(&[GRASS_BLOCK]))\n                    && !editor.surface_is_sealed(x, z)\n                    && !editor.is_lc_water(x, z)\n                {\n                    let random_choice: i32 = rng.random_range(0..1000);\n\n                    match random_choice {\n                        0..30 => {\n                            // Plants\n                            let plant_choice = match random_choice {\n                                0..5 => RED_FLOWER,\n                                5..10 => YELLOW_FLOWER,\n                                10..16 => BLUE_FLOWER,\n                                16..22 => WHITE_FLOWER,\n                                22..30 => FERN,\n                                _ => unreachable!(),\n                            };\n                            editor.set_block(plant_choice, x, 1, z, None, None);\n                        }\n                        30..90 => {\n                            // Grass\n                            editor.set_block(GRASS, x, 1, z, None, None);\n                        }\n                        90..105 => {\n                            // Oak leaves\n                            editor.set_block(OAK_LEAVES, x, 1, z, None, None);\n                        }\n                        105..120 => {\n                            // Only where land cover says woody, else a park\n                            // canopies its own meadows. 1/1000 for specimens.\n                            if random_choice == 105 || editor.land_cover_backs_trees(x, z) {\n                                Tree::create(\n                                    editor,\n                                    (x, 1, z),","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/louis-e/arnis/blob/34048924d9365795fb0d832e76140a3fbdc413d9/src/element_processing/leisure.rs#L99-L135","documentation":"In `generate_leisure`, a `random_choice` value is matched against ranges 0..5, 5..10, 10..16, 16..22, 22..30 to pick a flower/fern block, with `_ => unreachable!()`. The panic means the code produced a `random_choice` outside 0..30, i.e. the value generator and this match table are out of sync (note 0..5/5..10 are exclusive ranges, so 5 and 10 fall through correctly to later arms, but anything >= 30 does not).","triggerScenarios":"`random_choice` is generated with a range wider than 0..30 upstream (e.g. `rng.random_range(0..100)` or an inclusive upper bound), or the match arms were narrowed without updating the generator.","commonSituations":"Refactoring the plant distribution tables; changing the RNG range in one place but not the other; copy-pasting a similar match from another generator with different bounds.","solutions":["Find where `random_choice` is generated and make its range exactly 0..30 to match the arms","Replace `unreachable!()` with a fallback arm (`_ => FERN`) so out-of-range values degrade gracefully","Align both the generator range and the match arms in one commit and add a debug_assert for the bound"],"exampleFix":"// before\n_ => unreachable!(),\n// after\n_ => FERN, // safe fallback for any out-of-range value\n// and upstream: rng.random_range(0..30)","handlingStrategy":"fallback","validationCode":"debug_assert!((0..30).contains(&random_choice), \"random_choice {random_choice} outside plant table 0..30\");","typeGuard":"fn in_plant_range(v: i32) -> bool { (0..30).contains(&v) }","tryCatchPattern":null,"preventionTips":["Keep the RNG range and match arms in one constant (e.g. PLANT_TABLE_LEN)","Use a catch-all arm returning a default block","Add a test iterating the full generator range through the match"],"tags":["panic","unreachable","world-generation"],"backgroundTag":"unreachable-arm-reached","analyzedSha":"34048924d9365795fb0d832e76140a3fbdc413d9","analyzedAt":"2026-09-03T14:05:17.283Z","contentChangedAt":"2026-09-03T14:05:17.283Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}