probmods / webchurch

A Church to Javascript compiler (DEPRECATED)
Other
140 stars 15 forks source link

error handling for builtin argument structure violation #38

Closed feste closed 10 years ago

feste commented 10 years ago

Error "Cannot read property 'text' of undefined" for mistakes like:

trying to redefine a builtin function: (define fold 'hi)

trying to give a builtin function the wrong argument types: (mean third '(1 2 3)) (+ flip 1) (+ 'hi)

trying to give a builtin function too few arguments: (mean)

juliusc commented 10 years ago

For reference, this is broken because it still uses the mapped name as a definition, e.g.

(define + 1)

is compiled to

var church_builtins.plus = 1

This used to work when builtins weren't in a namespace, so it would just be

var plus = 1

I think we can easily fix this by detecting builtin names and not making them VariableDeclaration but an assignment, so we have

church_builtins.plus = 1

ngoodman commented 10 years ago

i fixed a bunch of these in 56e6a2ab27a4c70af7b8af4744065854d61ae420. didn't fix the assignment to builtins thing, since its a pain.

btw. why are builtins in a separate object?

juliusc commented 10 years ago

I put them in a separate object to remove the possibility of collision, especially with ProbJS builtins and the runtime environment.

juliusc commented 10 years ago

Fixed in 8471514275614a082cf4f4dd16bd78b2524af10b, introduced bug tracked in #42