AdeptLanguage / Adept

The Adept Programming Language
GNU General Public License v3.0
120 stars 8 forks source link

`print` bug #303

Open ghost opened 6 months ago

ghost commented 6 months ago
        each <double, double> AsymmetricPair in MyLinearMap {
            print(it.first + " : " + toString(it.second))
        }

will print gibberish.

This worked:

        each <double, double> AsymmetricPair in MyLinearMap {
            print(toString(it.first) + " : " + toString(it.second))
        }
IsaacShelton commented 6 months ago

Ah this is a weird issue. It's caused by trying to add a double to a String.

It doesn't differentiate order of adding double and String, it uses __add__(a String, b double), which incorrectly causes the value of the double to be after the value of the string.

There also seems to be an issues with there not being a way to have a __add__(a double, b String) function exist or be preferred, so this is a bug.

So yes, to get the correct behavior currently, the String part of the addition must be on the left.