-
Notifications
You must be signed in to change notification settings - Fork 171
Disable implicit casting by default and implement intrinsic functions for casting #1194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable implicit casting by default and implement intrinsic functions for casting #1194
Conversation
Thanks for working on this! This was on my TODO list, I think we want to do this change soon, since it's a breaking change. |
We don't need to add the compiler flag in this PR. If there is a need, we can add it later. |
@certik, The functions are mainly working fine. I have to work on the $ cat examples/expr2.py
from ltypes import i32
def main0():
x: f64
x = i32(6.8)
print(x)
main0()
$ lpython examples/expr2.py
semantic error: Type mismatch in assignment, the types must be compatible
--> examples/expr2.py:5:5
|
5 | x = i32(6.8)
| ^ ^^^ type mismatch ('f64' and 'i32')
Note: if any of the above error or warning messages are not clear or are lacking
context please report it to us (we consider that a bug that needs to be fixed). Here the error message should point to the complete |
5 | x = i32(6.8)
| ^ ^^^^^^^^ type mismatch ('f64' and 'i32') How can I fix this? |
You have to pass in the location information of the |
Any progress on this? I think we need to this early especially for the following cases,
@akshanshbhatt If you don't have time then let me know I can finish this as I anyways need this to happen. Thanks. |
Self-assigning. I will complete this tomorrow. Thanks. |
Closing in favour of #1271 |
Thanks for working on this, @czgdp1807! I just saw your previous messages on this PR; sorry for that - I was busy with my midsemester exams. |
Todo:
i32(x)
,i64(x)
,f32(x)
,f64(x)
).Add--allow-implicit-casting
compiler flag (Disallow all implicit casting #1006 (comment)).As of now, the example in #1142 gives the output as we expected -