HuoLanguage / huo

interpreted language written in C
MIT License
213 stars 21 forks source link

Undefined variables cause uninitialized values #13

Closed TheLoneWolfling closed 8 years ago

TheLoneWolfling commented 8 years ago

In for_do:

(print (reduce y acc cur (do
        (let x (* acc 98))
        (/ x curr)
    ) 1 ))

cur != curr. When division reads curr, it gets an unitialized value instead.

The simple fix would be to add something along the lines of the following:

                fprintf(stderr, "Undefined variable: %s\n", ast->content.data.str.body);
                exit(0);

at lines 88 / 89 of execute.c. In other words, if it couldn't find the variable, error out instead of just ignoring it.

incrediblesound commented 8 years ago

Fixed :-)