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 pointless/bad positional arguments. #1768

Open
moonheart08 opened this issue May 6, 2024 · 1 comment · May be fixed by #1770
Open

Lint for pointless/bad positional arguments. #1768

moonheart08 opened this issue May 6, 2024 · 1 comment · May be fixed by #1770
Labels
Compiler Involves the OpenDream compiler enhancement New feature or request

Comments

@moonheart08
Copy link
Contributor

moonheart08 commented May 6, 2024

In cases like https://github.com/Citadel-Station-13/Citadel-Station-13-RP/blob/69ce25bd79b41b7800e33c45ccb9a094a280c5ff/code/modules/gamemaster/actions/atmos_leak.dm#L20-L23

...
severity = pickweight(EVENT_LEVEL_MUNDANE = 8,
EVENT_LEVEL_MODERATE = 5,
EVENT_LEVEL_MAJOR = 3
)
...
// Event defines.
#define EVENT_LEVEL_MUNDANE        1
#define EVENT_LEVEL_MODERATE    2
#define EVENT_LEVEL_MAJOR        3
...

After preprocessing, this is

// This runtimes if the argument order is different.
severity = pickweight(1 = 8,
2 = 5,
3 = 3
)

which is equivalent to

severity = pickweight(8, 5, 3)

this is almost certainly unintentional, undoubtably does not do what the programmer intended (a BYOND classic frankly), and should probably be linted for.

@ike709 ike709 added enhancement New feature or request Compiler Involves the OpenDream compiler labels May 6, 2024
@ike709
Copy link
Collaborator

ike709 commented May 6, 2024

Added context I haven't verified for myself:
image

@moonheart08 moonheart08 linked a pull request May 6, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compiler Involves the OpenDream compiler enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants