Many forths have type annotations for function definitions, summarizing the cumulative stack effects. In some cases these are rigorously enforced by the compiler.
: SQUARE ( n1 -- n2 ) DUP * ;
I've never run into any checkers for these comments -- though https://stackoverflow.com/a/40321950/68707 indicates that checkers may exist. For example, Gforth (GNU Forth), one of the most popular and full-fledged Forth compilers doesn't do this.To do this, there are some limitations on how the stack can be used compared to regular Forth. (For example, both sides of an IF/ELSE must leave the same number of items on the stack with the same types, but they can have different values. An IF without an ELSE can never change the depth of the stack or what types are on it, since the implicit, empty ELSE side says that the stack doesn't change.) This generally isn't a huge problem, as the things you can't do in StrongForth are usually not such a good idea from a maintenance perspective in regular Forths.