Incorrect behaviour with StringMaker inside IEnumerator
Posted: Wed Jun 24, 2015 3:51 pm
There seems to be incorrect behaviour in StringMaker.makeString when it is called from an IEnumerator that resolves inside a call to StringMaker.makeString. StringMaker._level is being set one-too-high during the calls from inside the IEnumerator, as it is being treated as an IEnumerable by the StringMaker.
Demonstrated here:
Output:
EDITED OUT:
I originally had a proposed fix for this, but I've since realized it only covered some cases. When/if I can find a proper way to address this I will reply here.
Demonstrated here:
class Demo
def main
print .x
print .x.toList
def x as String*
print CobraImp._printStringMaker.level
print c'x'
print [1, 2, 3, 4].join('')
yield ''
Output:
- Code: Select all
1
c'x'
'1234'
['']
0
x
1234
['']
EDITED OUT:
I originally had a proposed fix for this, but I've since realized it only covered some cases. When/if I can find a proper way to address this I will reply here.