Skip to content

Conversation

@yashsain
Copy link
Contributor

@yashsain yashsain commented May 6, 2022

Fixes #433

case ASR::ttypeType::Tuple: {
return "tuple";
ASR::Tuple_t *t = (ASR::Tuple_t *)t;
return "tuple[" + type_to_str_python(t->m_type) + "]";
Copy link
Contributor

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, ...].

Copy link
Contributor Author

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.

Copy link
Collaborator

@Thirumalai-Shaktivel Thirumalai-Shaktivel May 7, 2022

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:

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...

@certik
Copy link
Contributor

certik commented May 6, 2022

Otherwise this looks good, I think that is how it should be done. Thanks for working on it.

t: tuple[i32, str]
t = (1, 2)

main() No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
main()
main()

tests/tests.toml Outdated

[[test]]
filename = "errors/test_tuple1.py"
asr = true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
asr = true
asr = true

@Smit-create
Copy link
Collaborator

Ah, I mistakenly closed this with a forced update, not sure why? Opened #495 with @yashsain 's initial commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add strict type checking in tuple

4 participants