proc test {oper elem value}  {
    switch -- $oper { add { lappend ::env($elem) $value } }
}
test add key "new value"

# This is a minimal case that will cause the problem.  Note that the following code fails in both 8.4 and 8.5:

proc test {oper elem value}  {
    lappend ::env($elem) $value
}
test add key "new value"

