HuoLanguage / huo

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

Unitialized print return value #12

Closed TheLoneWolfling closed 8 years ago

TheLoneWolfling commented 8 years ago

Currently, "(print (print 0))", for instance, isn't actually well-defined, as print doesn't actually initialize result.type.

Conditional jump or move depends on uninitialised value(s)
==5245==    at 0x8048E70: print (core_functions.c:9)
==5245==    by 0x804BBAA: execute (execute.c:99)
==5245==    by 0x8048889: main (huo.c:62)

This can be fixed by adding "result.type = 'u';" at line 101 of the execute section.

This does mean that "print" explicitly returns "undefined". I don't know what you want print to return. It might be that having print return the value printed would be better, for instance.

incrediblesound commented 8 years ago

Hmm, that's a tricky one. My instinct is to have print return undefined, but I will think about this one a little longer before I make that change. It may be nice, in some cases, to pass values through.

incrediblesound commented 8 years ago

OK print returns undefined now, I think that's the most intuitive solution.