"Your code checks out" lies to us?

Today I had code using an undeclared variable… compiler says “your code checks out”. And later a call to imp.wakeup with a typo in the name of the function… compiler says “your code checks out”.

Just for fun, I typed in the following program (note: this is the entirety of the program):

if (to_be || !to_be) {

And the check button once more says “Your code checks out!”

This does not at all match my expectation of what a “check” would do. Is this something that’s supposed to work (and I found a bug), or is this just not implemented yet?

The code check performs a basic syntax check, nothing more. It will not detect runtime errors, such as calling an undeclared function – these are revealed in the device log when you run the code. I don’t think we’ve ever suggested the initial check does anything more than look at syntax, but perhaps changing the response to ‘you code’s syntax checks out’ would make the checker’s role unambiguous.

Yes, that would be a better response.

Is there hope for a better check later? If you’ll forgive my directness, not checking until runtime is a rather big gap. It feels primitive and clashes with the rest of the environment (which feels modern).

“not checking until runtime is a rather big gap” - I have to disagree
@jpmartin, if you’re coming from a background of compiled, statically typed languages (as I did), this does take some getting used to. However, this can give you a lot of flexibility too. I’m enjoying the freedom of a dynamically typed environment. Nothing is evaluated until it is needed, meaning I can include or remove objects according to the run-time, not compile-time circumstances.

In Squirrel you can create new variable names at runtime, which means that detecting undeclared variables is, in the general case, equivalent to solving the halting problem. So while there might be hope for a “better” check, there is very much no hope at all for a perfect one.


Point taken, @coverdriven and @peter. I didn’t know new variable names could be created at runtime. My own Javascript experience has solidified my preference for more compile-time checking rather than less, but I understand it can be a matter of taste.

So personally if it were possible I would turn off the “create variables at runtime” feature and turn on the “made-up variable and function names don’t compile” option.

In theory imps aren’t tied to Squirrel as such – what they’re tied to is the Squirrel bytecode format and virtual machine. So (as a very blue-sky notion indeed) it might one day be possible to offer alternative languages that run on the same virtual machine, the way that Elixir runs on the Erlang VM or Clojure on the Java VM.