From 20607bcdfe1b4863c443028fafd29a9ae85620bf Mon Sep 17 00:00:00 2001 From: Josh Watzman Date: Sat, 7 May 2022 20:47:45 +0100 Subject: [PATCH] Fix renamer generating duplicate declarations in switch statements (#135) The entire switch statement is considered one scope, so we need to thread through the renamer environment so we don't generate duplicate definitions. It turns out the test case I added in #132 already hit this -- the output was not valid GLSL -- but I didn't notice :( --- src/renamer.fs | 3 +-- tests/unit/switch.expected | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/renamer.fs b/src/renamer.fs index 5edb23ad..e2d05c3b 100644 --- a/src/renamer.fs +++ b/src/renamer.fs @@ -317,8 +317,7 @@ module private RenamerImpl = | Default -> () let renCase env (l, sl) = renLabel l - renList env renStmt sl |> ignore - env + renList env renStmt sl renExpr env e renList env renCase cl |> ignore env diff --git a/tests/unit/switch.expected b/tests/unit/switch.expected index ac2e4b2b..48b746c5 100644 --- a/tests/unit/switch.expected +++ b/tests/unit/switch.expected @@ -37,8 +37,8 @@ float G() float k=2.4; return i+k; case 43: - float i=4.3; - return i+3.4; + float G=4.3; + return G+3.4; default: return 0.; }