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

Enable more OD pragmas #16885

Merged
merged 3 commits into from
Jan 12, 2025
Merged

Enable more OD pragmas #16885

merged 3 commits into from
Jan 12, 2025

Conversation

TiviPlus
Copy link
Member

@TiviPlus TiviPlus commented Jan 9, 2025

ProcArgumentGlobal, InvalidIndexOperation and AmbiguousInOrder

New Pragma: OD2211 - ProcArgumentGlobal from warning to error
A new pragma has been added for detecting this BYOND bug: https://www.byond.com/forum/post/2830750
When a proc argument begins with /var/ instead of var/, it creates a global variable instead of an argument.
/datum/proc/foo(/var/bar = 5)
return

/proc/main()
world.log << global.bar // This prints 5 in BYOND

Since this is obviously nonsense, elevating this pragma to an error is strongly encouraged. I have only found it in one SS13 codebase so far.

New Pragma: OD2304 - InvalidIndexOperation from warning to error
As of BYOND 515.1641, indexing datums (without an explicit operator[] overload) is now a runtime error in BYOND.

This new pragma detects such cases at compiletime, and elevating it to an error is strongly encouraged as previously-valid code that exists in SS13 will now runtime. It's a warning by default to maintain compatibility with older code & BYOND versions.

Example:
var/datum/foo = new
world.log << foo["bar"] // OD2304, Invalid index operation. datum[] index operations are not valid starting in BYOND 515.1641

New Pragma: OD3204 - AmbiguousInOrder from warning to error
A new pragma has been added for detecting ambiguous uses of in with unexpected behavior, similar to the lint in SpacemanDMM/DreamChecker. An example is "a" in a || "b" in b being parsed as ("a" in (a || "b")) in b. This is more comprehensive than SDMM's lint, and elevating this pragma to an error is strongly encouraged to detect logic errors.

@tgstation-server tgstation-server added the Tools Changes to the various development tools. label Jan 9, 2025
@TiviPlus
Copy link
Member Author

TiviPlus commented Jan 9, 2025

needs #16883

@TiviPlus TiviPlus marked this pull request as draft January 9, 2025 16:00
@TiviPlus
Copy link
Member Author

TiviPlus commented Jan 9, 2025

or the task at least so i can run od locally easily

@TiviPlus TiviPlus marked this pull request as ready for review January 11, 2025 18:26
@Lumipharon Lumipharon merged commit b2fea47 into tgstation:master Jan 12, 2025
41 checks passed
@TiviPlus TiviPlus deleted the newodpragmas branch January 13, 2025 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tools Changes to the various development tools.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants