Problem description:
Hi, the problem that I am facing is that the DM compiler will not warn if non-constant expressions are used in the branches of a switch statement. Instead it seems that the switch statement fails silently.
Has anyone else encountered this problem?
Mar 4 2015, 7:32 am
|
|
Examples?
|
No, in your example you are still using constant expressions in the switch. I mean something like this:
/mob/example The problem that was reported to me was that in the above case src will always recieve "something else" as all of the switch statement branches fail. Now before anyone posts any more "code" answers, I want to make this clear because it seems like people aren't getting it. I am not looking for a code answer. I am not asking for help writing DM code, and that is not the problem. I am already aware that switch does not work with non-constant expressions. I am familiar with the DM documentation where in chapter 6.19 it says switch works with constant expressions. This is not the issue. The problem I am facing is that if you do use it with non-constant expressions, DM compiles it without errors and the code fails silently at runtime. This is a huge problem when you are working with a codebase that has hundreds of source files that have been written by dozens of people over more than five years. I am looking for a way to get DM to produce an error when you use switch with non-constant expressions. That way when someone who is less familiar with DM does make this mistake, we know about it right away. If this is the wrong forum please let me know. |