Skip to content

Adding int and double cannot be assigned to an integer. #183

stauntonknight opened this Issue Apr 20, 2012 · 3 comments

3 participants


Ran the command, mirah -e "a=1;a=1+2.0" and it reported an error.
Same issue with the gist

I was expecting it to do some automatic type casting or perhaps treat a as a double since I never said it was an int.


I think this is expected behaviour for a language with local type inferencing in a statically-typed language like Mirah.

a = 1 # declares a variable 'a', integer type inferred.
a = 1 + 2.0 # type error: 'a' is not a double.


I am not sure about that, I would still expect a to expand from "inferred" type int to double unless I have used some feature which is there only in int and not in double. For e.g. if I had done a! somewhere, then it would make sense for compiler to complain.

Moreover, will we not support automatic type casting or automatic downgrading, so that assigning a double to int should automatically strip the fractional part.

ribrdb commented Feb 18, 2013

This works with master:
$ bin/mirah -e "a=1;a=1+2.0;puts a"

@ribrdb ribrdb closed this Feb 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.