ckknight / gorillascript

GorillaScript is a compile-to-JavaScript language designed to empower the user while attempting to prevent some common errors.
MIT License
300 stars 34 forks source link

Fix for constants in do statements #153

Closed kkirby closed 9 years ago

kkirby commented 10 years ago

In the instance of having a "do" statement with a constant defined, and a macro inside of the do statement that tries to get the value of the constant, the constant wouldn't be defined. I simply added macro-expand-all to evaluate the constant. This may or may not be the right fix for the problem.

The issue appears to only occur when the do statement has variable assignments. See below for an example:

macro getConst()
    let value = @getConstValue \VALUE
    AST $value

// Works
do
    const VALUE = \asdf
    console.log getConst()

// Does not work
do A = B
    const VALUE = \asdf
    console.log getConst()