probmods / webchurch

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

Assigning value to `mem` gives nonsense output. #61

Closed PrajitR closed 10 years ago

PrajitR commented 10 years ago

Assigning a value to mem instead of a function ((define (example) (mem 0.5))) gives this confusing and unhelpful output (which is not registered as an error):

(function ()
    {
        var str = JSON.stringify(arguments)
        var val = cache[str]
        if (val === undefined)
        {
            val = fn.apply(this, arguments)
            cache[str] = val
        }
        return val
    } function ()
    {
        var str = JSON.stringify(arguments)
        var val = cache[str]
        if (val === undefined)
        {
            val = fn.apply(this, arguments)
            cache[str] = val
        }
        return val
    } function ()
    {
        var str = JSON.stringify(arguments)
        var val = cache[str]
        if (val === undefined)
        {
            val = fn.apply(this, arguments)
            cache[str] = val
        }
        return val
    })

Looks like the innards of the compiler are leaking out. Assigning a value to mem should error out with mem cannot be assigned a value. mem must be assigned a function.

Also, thanks for the fantastic book!

longouyang commented 10 years ago

Should be fixed in 605be0f36c0ffd1e538af8bba8860390effedf28

Thanks for bringing this up, Prajit!