Skip to content

Commit

Permalink
Fix renamer generating duplicate declarations in switch statements (#135
Browse files Browse the repository at this point in the history
)

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 :(
  • Loading branch information
jwatzman committed May 7, 2022
1 parent 50b12fe commit 20607bc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/renamer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ module private RenamerImpl =
| Default -> ()
let renCase env (l, sl) =
renLabel l
renList env renStmt sl |> ignore<Env>
env
renList env renStmt sl
renExpr env e
renList env renCase cl |> ignore<Env>
env
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/switch.expected
Original file line number Diff line number Diff line change
Expand Up @@ -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.;
}
Expand Down

0 comments on commit 20607bc

Please sign in to comment.