keriwarr / orangejoos

JOOS1W Compiler, written in Crystal
0 stars 1 forks source link

typing: fix a lot of type changing rules #53

Closed lgo closed 6 years ago

lgo commented 6 years ago

Major fixes to types to make a distinction between operations that are allowed for assignability and for casting. Casting can allow sub-classes and super-classes to be changed, where as assigning does not. There was also an issue that made Type == Type always true for any instance types.

There are also fixes around when types can be converted between standard numerics and chars.

A char can be returned as an int (char -> int). Any numeric can be casted with a char.

Additional rules of casting numerics: Only allow int <- int, not: {byte,short} <- int Only allow {short, int} <- short, not: byte <- short Disallow int[] <- byte[]. int <- byte is allowed though.

+14 tests Also includes added tests a nameres fix that made method signature matching more strict, accounting for ~2-3 tests.

lgo commented 6 years ago

PTAL @keriwarr (or just let it 💸)