jckarter / clay

The Clay programming language
http://claylabs.com/clay
Other
404 stars 34 forks source link

evalStringTableConstant: write trailing \0 into correct location #492

Closed stepancheg closed 11 years ago

stepancheg commented 11 years ago

I found a bug in code, but I cannot reproduce it. evalStringTableConstant function is called (I checked in debugger), but result seems to be ignored somehow. For instance, I tried this test:

println(#(stringTableConstant("abc")^));

It outputs 3, and not junk as I thought.

Any idea how to write a unit test for the issue?

jckarter commented 11 years ago

The patch looks good; nice catch. String table constants are emitted as a length followed by the string contents, and the return value of stringTableConstant is a pointer to the length, so 3 is the correct answer for your example.

stepancheg commented 11 years ago

After some thinking I managed to reproduce a problem: 9313b1ffff01830b2c9759fdd9199066c3fbcadb.