Debug
Runtime
The standard library can swap out the debug package depending on the runtime. If debugging is disabled all the methods become static no-ops and the compiler will remove all debugging logic.
Break
Calling debug.Break() will cause the program to break. And this can be wrapped in an if. When the program is in break mode we can inspect variables, stack and should even be able to replace values and run arbitrary code.
Hotswapping
V allows this. Not sure how it works (it's trivial in some cases, impossible in others).
Socket
I'll have to dig into this, but the debugger will expose itself on a socket. Tools can connect on that socket. Out of the box there should be a command line version and web version.
Assert
Adds checks. If the compiler can show that an assert is not true, it will return an error. If an assert is untrue at runtime, it can be set to either return an error or log an error.
For unit testing, code coverage does not include blocks that only contain asserts.
Assert.
- Never: always fails
- True
- Inline: fails if the function cannot be inlined
- Pure: fails if the function is not pure
- Escape(var): fails if the variable cannot be allocated on the stack