Open jorendorff opened 11 years ago
I just realized that since globals are not rebindable, you could actually do a type-checking pass over the code.
So for example rep {x => add x 1}
which omits the first (integer) argument; we could reject this in a type analysis pass with a pretty nice error message ("the first argument to rep
has to be an integer") and likewise we know that the return value is null, so rep count action1 action2
is an error ("you’re passing 3 arguments to rep
but it only takes 2").
Also, scopes are static, so we can and should detect unbound variable references (and names defined more than once in a single scope, that's just a bug).
Errors now have location information but the UI doesn't use it (separate bug).
Keeping this open for treating identifier typos as static errors.
Errors have got to have position information or it's just impossible to tell what went wrong. Both syntax errors and runtime errors.
Function arity problems are going to be rampant. The language is like ML but without any type checking.