Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint for non-const switch range cases #322

Open
ike709 opened this issue May 23, 2022 · 0 comments
Open

Lint for non-const switch range cases #322

ike709 opened this issue May 23, 2022 · 0 comments

Comments

@ike709
Copy link

ike709 commented May 23, 2022

See http://www.byond.com/forum/post/2750423

tl;dr BYOND doesn't throw a compiler error if you use a non-const in a switch range case (see code below) and instead silently uses null in place of the non-const. Since lummox hasn't fixed it after over 5 months I'm hoping someone will add a lint for it.

Example code:

proc/test_code()
    var/T = 5 // Making this "var/const/T = 5" fixes it. Also, to clarify, this bug applies to non-local vars too.
    switch(1)
        if(T to 10e31)
            world.log << "Yes" // Actual result, because T is actually "null"
        else
            world.log << "No" // Expected result, because 1 isn't in the range of 5 to 10e31. Well actually the real expected result is a compiler error for T being non-const.

This bug only applies to range cases, aka the ones using A to B.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants