Skip to content
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

Fixed scoping issues of for loops in global scope #2672

Merged
merged 10 commits into from
May 1, 2024

Conversation

tanay-man
Copy link
Contributor

@tanay-man tanay-man commented Apr 28, 2024

fixes #2608 , fixes #1475.

@kmr-srbh
Copy link
Contributor

@tanay-man I think this should also fix #1475. Could you please verify it?

@kmr-srbh
Copy link
Contributor

Please make the changes to handle subscripts also.

@tanay-man
Copy link
Contributor Author

tanay-man commented Apr 28, 2024

@tanay-man I think this should also fix #1475. Could you please verify it?

It does fix the issue.

@kmr-srbh
Copy link
Contributor

It does fix the issue.

Great! Please link the PR to close that too.

@tanay-man
Copy link
Contributor Author

Please make the changes to handle subscripts also.

The same solution doesn't work for the subscripts. It produces asr but it cannot be converted to llvm further. I'll have to look into it for further analysis.

@kmr-srbh
Copy link
Contributor

Please make the changes to handle subscripts also.

The same solution doesn't work for the subscripts. It produces asr but it cannot be converted to llvm further. I'll have to look into it for further analysis.

I tested the changes locally. They work for both subscripts of strings and lists.

List

from lpython import i32

i: i32
my_list: list[i32] = [1, 2, 3, 4, 5]
for i in my_list[1:3]:
    print(i)
(base) saurabh-kumar@Awadh:~/Projects/System/lpython$ ./src/bin/lpython ./examples/example.py
2
3

String

c: str
s: str = "abcde"
for c in s[1:3]:
    print(c)
(base) saurabh-kumar@Awadh:~/Projects/System/lpython$ ./src/bin/lpython ./examples/example.py
b
c

@kmr-srbh
Copy link
Contributor

kmr-srbh commented Apr 28, 2024

Issue #2608 , Issue #1475.

@tanay-man you can change this to 'fixes #2608, fixes #1475' to link this PR to the issues. 👍

@certik certik marked this pull request as draft April 29, 2024 19:39
Copy link
Collaborator

@Shaikh-Ubaid Shaikh-Ubaid left a comment

Choose a reason for hiding this comment

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

I shared few comments. Apart from the removed c label for one of the tests, the rest of the things look good to me.

I think this will be good to merge after the shared comments are resolved. Thanks for this. Great work @tanay-man !

src/lpython/semantics/python_ast_to_asr.cpp Outdated Show resolved Hide resolved
src/lpython/semantics/python_ast_to_asr.cpp Outdated Show resolved Hide resolved
integration_tests/CMakeLists.txt Outdated Show resolved Hide resolved
@tanay-man tanay-man marked this pull request as ready for review April 30, 2024 05:07
Copy link
Collaborator

@Shaikh-Ubaid Shaikh-Ubaid left a comment

Choose a reason for hiding this comment

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

It looks good to me. Thanks for this! Great work @tanay-man!

@Shaikh-Ubaid Shaikh-Ubaid enabled auto-merge (squash) May 1, 2024 10:21
@Shaikh-Ubaid Shaikh-Ubaid merged commit d7121dd into lcompilers:main May 1, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants