* Update ScriptDeath to extend Error
- Rename the "name" property to "hostname" so that it doesn't clash with inherited Error.name property.
- Extend Error, this way if a user ends up catching it they can:
- Test the type of error caught (name) and ignore it if desired
- Get a stack trace and find out where they went wrong
- Not require special case error printing logic for catching things that are neither strings, nor Error objects.
It is possible (but unlikely) that this could make killing scripts slower in some circumstances.
To make this simpler, there is now a general-purpose util for getting
random bigints. I don't know if anyone else will use it, but it makes
this code simpler.
I also rejiggered the type-checking on contracts a little more, because
the previous refactor didn't quite catch all the mistakes that could be
made.
* FIX: import resolution in code editor
Since I did not find any callback where we could just load imports
on-demand, I opted for just loading all scripts from the server where
a given script was opened from command line. This does not include
scripts which are already open, only files which are not yet opened
will be loaded.
* MISC: Refactor coding contracts for type safety
This refactor does three things without any behavior changes:
* Adds type safety by introducing generic type parameters to the coding
contract definitions, so they can use concrete types instead of
"unknown". This also eliminates a bunch of boilerplate casts.
* Removes the unneeded CodingContractType class. We can use the metadata
type directly.
* Introduces a new hidden state to coding contracts. Instead of
generating and storing the data (which is what is shown to the user as
the problem's input), the state is stored instead. This allows
problems to (for instance) generate the answer up-front, and check the
solution directly against the answer, instead of needing to embed a
solver in the problem (which can then easily be ripped from the source
code).
For compatibility, state == data by default. I plan to make use of this
feature in a followup, but it is unused currently.