Files
Bubberstation/code/__DEFINES/procpath.dm
SkyratBot 6e360e1234 [MIRROR] OpenDream TypeMaker Prep (#26762)
* 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 <ike709@users.noreply.github.com>
2024-03-06 22:15:12 -05:00

27 lines
1.2 KiB
Plaintext

/// Represents a proc or verb path.
///
/// Despite having no DM-defined static type, proc paths have some variables,
/// listed below. These are not modifiable, but for a given procpath P,
/// `new P(null, "Name", "Desc")` can be used to create a new procpath with the
/// same code but new `name` and `desc` values. The other variables cannot be
/// changed in this way.
///
/// This type exists only to act as an annotation, providing reasonable static
/// typing for procpaths. Previously, types like `/atom/verb` were used, with
/// the `name` and `desc` vars of `/atom` thus being accessible. Proc and verb
/// paths will fail `istype` and `ispath` checks against `/procpath`.
/procpath
// Although these variables are effectively const, if they are marked const
// below, their accesses are optimized away.
/// A text string of the verb's name.
var/name = null as text|null
/// The verb's help text or description.
var/desc = null as text|null
/// The category or tab the verb will appear in.
var/category = null as text|null
/// Only clients/mobs with `see_invisibility` higher can use the verb.
var/invisibility = null as num|null
/// Whether or not the verb appears in statpanel and commandbar when you press space
var/hidden = null as num|null