[GH-ISSUE #6809] Shader packs: a non-void function that can reach its end without a return fails to translate #2224

Closed
opened 2026-11-02 15:53:09 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @arslanarm on GitHub (Nov 2, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6809

Originally assigned to: @arslanarm on GitHub.

🤖 Filed by arslanarm's AI agent (Claude Code, Claude Opus 5.5), not by arslanarm personally.

What happens: a non-void function whose last statement is not a return (control can reach the closing brace) fails to translate:

Function [4] 'f' is invalid: The `return` expression None does not match the declared return type Some([3])

GLSL allows this: such a function is valid, only the value it gives back when it reaches the end is undefined. glslangValidator (1.4.363) compiles the example below without an error.

An example (written for this issue, composite.fsh):

#version 330
in vec2 uv;
float f(float x) {
    for (int i = 0; i < 4; i++) {
        if (x > float(i)) return float(i);
    }
}
/* DRAWBUFFERS:0 */
layout(location = 0) out vec4 c;
void main() { c = vec4(f(uv.x)); }

Expected: it translates (the missing value can be anything, e.g. zero).

Packs it skips programs in (run as black boxes with real_packs on main 3a264943c):

  • Lux v1.3: composite5 in all three dimensions (lib/post/tonemap.glsl:4, function MaxIdx).
  • RedHat v34.3.1: composite in all three dimensions (program/composite.glsl:547 and the nether/end copies, function dynamicExposure).
Originally created by @arslanarm on GitHub (Nov 2, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6809 Originally assigned to: @arslanarm on GitHub. > 🤖 Filed by arslanarm's AI agent (Claude Code, Claude Opus 5.5), not by arslanarm personally. **What happens:** a non-`void` function whose last statement is not a `return` (control can reach the closing brace) fails to translate: ``` Function [4] 'f' is invalid: The `return` expression None does not match the declared return type Some([3]) ``` GLSL allows this: such a function is valid, only the value it gives back when it reaches the end is undefined. `glslangValidator` (1.4.363) compiles the example below without an error. **An example** (written for this issue, `composite.fsh`): ```glsl #version 330 in vec2 uv; float f(float x) { for (int i = 0; i < 4; i++) { if (x > float(i)) return float(i); } } /* DRAWBUFFERS:0 */ layout(location = 0) out vec4 c; void main() { c = vec4(f(uv.x)); } ``` Expected: it translates (the missing value can be anything, e.g. zero). **Packs it skips programs in** (run as black boxes with `real_packs` on main 3a264943c): - Lux v1.3: `composite5` in all three dimensions (`lib/post/tonemap.glsl:4`, function `MaxIdx`). - RedHat v34.3.1: `composite` in all three dimensions (`program/composite.glsl:547` and the nether/end copies, function `dynamicExposure`).
Author
Owner

@arslanarm commented on GitHub (Nov 2, 2026):

🤖 Agent: /claim

Claimed by arslanarm's AI agent (Claude Code, Claude Opus 5.5), not by arslanarm personally.

<!-- gh-comment-id:6570406775 --> @arslanarm commented on GitHub (Nov 2, 2026): 🤖 Agent: /claim Claimed by arslanarm's AI agent (Claude Code, Claude Opus 5.5), not by arslanarm personally.
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#2224
No description provided.