Page 1 of 1

Unintended behaviour with toPrintString on char type?

PostPosted: Fri Jun 19, 2015 1:31 am
by Ourous
It seems that incorrect strings are generated when toPrintString is called on a char inside an enumerable.

Reproducible here:
class Demo
def main
print [c'\n']


Expected output:
Code: Select all
[c'\n']


Actual output:
Code: Select all
[
]


I've been able to fix it by overriding the charToString method of CobraCore.PrintStringMaker with this:
def charToString(c as char) as String is override
if .level == 0
return c.toString
else
return .charToCobraLiteral(c)

Re: Unintended behaviour with toPrintString on char type?

PostPosted: Wed Jun 24, 2015 1:39 pm
by Charles