From b022ad13d46b77774d7fb270507f1716c46ba8a0 Mon Sep 17 00:00:00 2001 From: NovaBot <154629622+NovaBot13@users.noreply.github.com> Date: Thu, 7 Mar 2024 01:32:27 -0500 Subject: [PATCH] [MIRROR] OpenDream TypeMaker Prep (#1292) * OpenDream TypeMaker Prep (#81830) ## About The Pull Request OpenDream is adding support for proc and var typechecking using `as` in https://github.com/OpenDreamProject/OpenDream/pull/1705 BYOND silently ignores most uses of `as`, but OpenDream can leverage it for static typing. E.g. the following code will error in OpenDream while doing nothing in BYOND: ``` /datum/proc/meep() as text return "meep" /datum/foobar/meep() return 5 ``` `Warning OD2701 at code.dm:29:8: /datum/foobar/meep(): Invalid return type "num", expected "text"` Pragmas allow these type emissions to be warnings, errors, or suppressed entirely. This PR modifies some existing uses of `as` in TG to prevent `ImplicitNullType` warnings (which is when a var with a null value doesn't explicitly have the `|null` type specified). This specific pragma is a bit opinionated so it could simply be disabled, but since this has no impact on BYOND behavior I don't see a reason not to fix these examples anyways. ## Why It's Good For The Game Typechecking. ## Changelog no cl no fun * OpenDream TypeMaker Prep --------- Co-authored-by: ike709 --- code/__DEFINES/procpath.dm | 10 +++++----- code/modules/mob/living/living.dm | 2 +- code/modules/mob/mob_transformation_simple.dm | 2 +- modular_nova/modules/mentor/code/mentorhelp.dm | 2 +- modular_nova/modules/mentor/code/mentorsay.dm | 2 +- .../code/soulcatcher/soulcatcher_mob.dm | 2 +- modular_nova/modules/panicbunker/code/panicbunker.dm | 4 ++-- modular_nova/modules/verbs/code/looc.dm | 4 ++-- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/code/__DEFINES/procpath.dm b/code/__DEFINES/procpath.dm index 642ca3eab6c..16716d6c091 100644 --- a/code/__DEFINES/procpath.dm +++ b/code/__DEFINES/procpath.dm @@ -15,12 +15,12 @@ // below, their accesses are optimized away. /// A text string of the verb's name. - var/name as text + var/name = null as text|null /// The verb's help text or description. - var/desc as text + var/desc = null as text|null /// The category or tab the verb will appear in. - var/category as text + var/category = null as text|null /// Only clients/mobs with `see_invisibility` higher can use the verb. - var/invisibility as num + var/invisibility = null as num|null /// Whether or not the verb appears in statpanel and commandbar when you press space - var/hidden as num + var/hidden = null as num|null diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index e21fb921429..cc28cf65e0a 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -524,7 +524,7 @@ log_message("points at [pointing_at]", LOG_EMOTE) visible_message("[span_name("[src]")] points at [pointing_at].", span_notice("You point at [pointing_at].")) -/mob/living/verb/succumb(whispered as null) +/mob/living/verb/succumb(whispered as num|null) set hidden = TRUE if (!CAN_SUCCUMB(src)) if(HAS_TRAIT(src, TRAIT_SUCCUMB_OVERRIDE)) diff --git a/code/modules/mob/mob_transformation_simple.dm b/code/modules/mob/mob_transformation_simple.dm index 6d2a8a9850d..56cd102a59b 100644 --- a/code/modules/mob/mob_transformation_simple.dm +++ b/code/modules/mob/mob_transformation_simple.dm @@ -2,7 +2,7 @@ //This proc is the most basic of the procs. All it does is make a new mob on the same tile and transfer over a few variables. //Returns the new mob //Note that this proc does NOT do MMI related stuff! -/mob/proc/change_mob_type(new_type = null, turf/location = null, new_name = null as text, delete_old_mob = FALSE) +/mob/proc/change_mob_type(new_type = null, turf/location = null, new_name = null as text|null, delete_old_mob = FALSE) if(isnewplayer(src)) to_chat(usr, span_danger("Cannot convert players who have not entered yet.")) diff --git a/modular_nova/modules/mentor/code/mentorhelp.dm b/modular_nova/modules/mentor/code/mentorhelp.dm index d3bc2f343bd..a6db0c5b7f5 100644 --- a/modular_nova/modules/mentor/code/mentorhelp.dm +++ b/modular_nova/modules/mentor/code/mentorhelp.dm @@ -1,4 +1,4 @@ -/client/verb/mentorhelp(msg as text) +/client/verb/mentorhelp(msg as text|null) set category = "Mentor" set name = "Mentorhelp" diff --git a/modular_nova/modules/mentor/code/mentorsay.dm b/modular_nova/modules/mentor/code/mentorsay.dm index 77d83d3c936..01cc4e6397c 100644 --- a/modular_nova/modules/mentor/code/mentorsay.dm +++ b/modular_nova/modules/mentor/code/mentorsay.dm @@ -1,4 +1,4 @@ -/client/proc/cmd_mentor_say(msg as text) +/client/proc/cmd_mentor_say(msg as text|null) set category = "Mentor" set name = "Msay" //Gave this shit a shorter name so you only have to time out "msay" rather than "mentor say" to use it --NeoFite set hidden = 1 diff --git a/modular_nova/modules/modular_implants/code/soulcatcher/soulcatcher_mob.dm b/modular_nova/modules/modular_implants/code/soulcatcher/soulcatcher_mob.dm index 94a4601e94d..54f25fb210a 100644 --- a/modular_nova/modules/modular_implants/code/soulcatcher/soulcatcher_mob.dm +++ b/modular_nova/modules/modular_implants/code/soulcatcher/soulcatcher_mob.dm @@ -127,7 +127,7 @@ room.send_message(message, src, FALSE) return TRUE -/mob/living/soulcatcher_soul/me_verb(message as text) +/mob/living/soulcatcher_soul/me_verb(message as text|null) message = trim(copytext_char(sanitize(message), 1, MAX_MESSAGE_LEN)) if(!message) return FALSE diff --git a/modular_nova/modules/panicbunker/code/panicbunker.dm b/modular_nova/modules/panicbunker/code/panicbunker.dm index 1054fdfa851..410853d3f21 100644 --- a/modular_nova/modules/panicbunker/code/panicbunker.dm +++ b/modular_nova/modules/panicbunker/code/panicbunker.dm @@ -1,6 +1,6 @@ GLOBAL_LIST_EMPTY(bunker_passthrough) -/client/proc/addbunkerbypass(ckeytobypass as text) +/client/proc/addbunkerbypass(ckeytobypass as text|null) set category = "Admin" set name = "Add PB Bypass" set desc = "Allows a given ckey to connect despite the panic bunker for a given round." @@ -14,7 +14,7 @@ GLOBAL_LIST_EMPTY(bunker_passthrough) log_admin("[key_name(usr)] has added [ckeytobypass] to the current round's bunker bypass list.") message_admins("[key_name_admin(usr)] has added [ckeytobypass] to the current round's bunker bypass list.") -/client/proc/revokebunkerbypass(ckeytobypass as text) +/client/proc/revokebunkerbypass(ckeytobypass as text|null) set category = "Admin" set name = "Revoke PB Bypass" set desc = "Revoke's a ckey's permission to bypass the panic bunker for a given round." diff --git a/modular_nova/modules/verbs/code/looc.dm b/modular_nova/modules/verbs/code/looc.dm index 77eb5d02d68..fba9af46577 100644 --- a/modular_nova/modules/verbs/code/looc.dm +++ b/modular_nova/modules/verbs/code/looc.dm @@ -1,11 +1,11 @@ -/client/verb/looc(msg as text) +/client/verb/looc(msg as text|null) set name = "LOOC" set desc = "Local OOC, seen only by those in view." set category = "OOC" looc_message(msg) -/client/verb/looc_wallpierce(msg as text) +/client/verb/looc_wallpierce(msg as text|null) set name = "LOOC (Wallpierce)" set desc = "Local OOC, seen by anyone within 7 tiles of you." set category = "OOC"