A problem with sv_Construct?? :unsure:
No, sv_Construct is working correctly: it constructs a new string and returns its ID, nothing more. It has no control over what the ID is used for, e.g. assignment or whatever.
When you use "let" to assign to a variable, the right-hand side of the assignment is evaluated as an OBSE expression. What that means, as far as I can tell, is that any strings created by the expression are flagged as temporary, to be destroyed automatically at the end of the frame. When you assign
to a string_var with "let", it modifies the existing string. So in your "let" example, if svPrefix currently refers to string ID #1, sv_Construct will create string #2, "let" will copy the contents of string #2 into string #1, and then string #2 will be released automatically. Note that svPrefix still refers to string #1, but the content of that string has changed.
When you use "set" to assign a variable, on the other hand, it doesn't know anything about strings so it just assigns the numeric value. You end up storing the number 2 into svPrefix, replacing the number 1, resulting in string #1 being leaked.
(Note, I'm not 100% certain about the details of "let" assignment because it's been awhile since I did a bunch of testing of its behavior. It might actually allocate a new string and free the old one at the same time, rather than modifying the contents of the existing string; I'm not sure. But the point is that "let" knows that string_vars are more than just integers, and "set" does not.)