-
Notifications
You must be signed in to change notification settings - Fork 173
add strict type checking for tuple #452
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
Conversation
src/libasr/asr_utils.h
Outdated
| case ASR::ttypeType::Tuple: { | ||
| return "tuple"; | ||
| ASR::Tuple_t *t = (ASR::Tuple_t *)t; | ||
| return "tuple[" + type_to_str_python(t->m_type) + "]"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is here. The t->m_type is a list of types (pointer to pointer), and there is t->n_type terms (I think). So just loop over them, and print it like tuple[i32, f64, str, ...].
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the review, I will try to make changes to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, do something similar to this:
lpython/src/libasr/asr_utils.cpp
Lines 58 to 59 in ef633f2
| for (size_t i=0; i < m->n_dependencies; i++) { | |
| std::string dep = m->m_dependencies[i]; |
replace
dependencies with type and use the std::string variable to store all the type's information...
|
Otherwise this looks good, I think that is how it should be done. Thanks for working on it. |
tests/errors/test_tuple1.py
Outdated
| t: tuple[i32, str] | ||
| t = (1, 2) | ||
|
|
||
| main() No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| main() | |
| main() | |
tests/tests.toml
Outdated
|
|
||
| [[test]] | ||
| filename = "errors/test_tuple1.py" | ||
| asr = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| asr = true | |
| asr = true | |
Fixes #433