[PR #7753] Shader #if: skip division errors on the side && / || short-circuits #7800

Open
opened 2026-11-03 07:24:18 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7753
Author: @ClickingMaster
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: fix/shader-if-short-circuit


📝 Commits (1)

  • b9aac00 Shader #if: skip division errors on the side && / || short-circuits

📊 Changes

1 file changed (+25 additions, -3 deletions)

View changed files

📝 crates/horizon-shaders/src/condition.rs (+25 -3)

📄 Description

🤖 Opened by ClickingMaster's AI agent (Claude Code, Claude Sonnet 5.5), not by ClickingMaster personally.

Fixes #7678

Cause: Parser::binary in crates/horizon-shaders/src/condition.rs parsed and applied both operands of && / ||, so apply raised "division by zero" even when the operator skips that operand.

Fix: when the left operand decides the result (|| with a true left, && with a false left), the right side is parsed with a quiet flag, and apply yields 0 for / and % by zero there. The unskipped side still errors.

Test: short_circuit_skips_guarded_division covers AMOUNT != 0 && 100 / AMOUNT > 5 (0), AMOUNT == 0 || 100 / AMOUNT > 5 (1), and that unguarded cases still error. It fails before the fix (division by zero error) and passes after; cargo test -p horizon-shaders condition tests: 9 passed.

Self-check

  • cargo fmt --all -- --check
  • cargo clippy -p horizon-shaders --all-targets -- -D warnings
  • cargo test -p horizon-shaders (condition tests)
  • tools/port_ledger.py check: no ledger built here
  • pr_ready.py not run: no ALSA headers

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/7753 **Author:** [@ClickingMaster](https://github.com/ClickingMaster) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/shader-if-short-circuit` --- ### 📝 Commits (1) - [`b9aac00`](https://github.com/horizon-rust/horizon/commit/b9aac0067421bd63f0251d090b6ff1e83d2f5213) Shader #if: skip division errors on the side && / || short-circuits ### 📊 Changes **1 file changed** (+25 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-shaders/src/condition.rs` (+25 -3) </details> ### 📄 Description > 🤖 Opened by ClickingMaster's AI agent (Claude Code, Claude Sonnet 5.5), not by ClickingMaster personally. Fixes #7678 **Cause:** `Parser::binary` in `crates/horizon-shaders/src/condition.rs` parsed and applied both operands of `&&` / `||`, so `apply` raised "division by zero" even when the operator skips that operand. **Fix:** when the left operand decides the result (`||` with a true left, `&&` with a false left), the right side is parsed with a `quiet` flag, and `apply` yields 0 for `/` and `%` by zero there. The unskipped side still errors. **Test:** `short_circuit_skips_guarded_division` covers `AMOUNT != 0 && 100 / AMOUNT > 5` (0), `AMOUNT == 0 || 100 / AMOUNT > 5` (1), and that unguarded cases still error. It fails before the fix (division by zero error) and passes after; `cargo test -p horizon-shaders` condition tests: 9 passed. **Self-check** - [x] `cargo fmt --all -- --check` - [x] `cargo clippy -p horizon-shaders --all-targets -- -D warnings` - [x] `cargo test -p horizon-shaders` (condition tests) - [ ] `tools/port_ledger.py check`: no ledger built here - [ ] pr_ready.py not run: no ALSA headers 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#7800
No description provided.