Forums

Unintended behaviour with toPrintString on char type?

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Unintended behaviour with toPrintString on char type?

Postby Ourous » Fri Jun 19, 2015 1:31 am

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)
Ourous
 
Posts: 10

Re: Unintended behaviour with toPrintString on char type?

Postby Charles » Wed Jun 24, 2015 1:39 pm

Charles
 
Posts: 2510
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 5 guests

cron