[cpl] [Tema2] Testul assign-mismatch2

Cristian Hurezeanu cristian.hurezeanu at gmail.com
Tue Dec 1 06:40:55 EET 2015


In testul asta:

class Main inherits IO
    print Int x :
        local String s; end;
        s = if x < 0 then
                "Minus " +  -x;
            else
                x;
            end
        ;
        [out s];
    end;

    main :
        [print -4];
        [print 25];
    end;
end;

TestRig-ul zice ca trebuie sa arunce IncompatibleOperandsException. Eu vad
aici doar 3 cazuri posibile:
1. s = ... . Ramura then e un string, iar cea else e un int (care se
converteste implicit la string conform manualului)
2. "Minus" + -x. String + int, se converteste implicit la string.
3. x < 0. Int < Int

Unde e eroarea mai exact?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cursuri.cs.pub.ro/pipermail/cpl/attachments/20151201/236c7d7c/attachment.html>


More information about the cpl mailing list