Skip to content

Conversation

@kmr-srbh
Copy link
Contributor

@kmr-srbh kmr-srbh commented May 10, 2024

from lpython import i32, f64

# global scope
my_first_list: list[i32] = [1, 2, 3, 4, 5]
print(my_first_list)

my_first_list.append(4)
my_first_list.remove(2)
print(my_first_list.count(4))
my_first_list.insert(0, 1)
my_first_list.clear()

# local scope
def f():
    my_first_list: list[i32] = [1, 2, 3, 4, 5]
    print(my_first_list)

    my_first_list.append(4)
    my_first_list.remove(2)
    print(my_first_list.count(4))
    my_first_list.insert(0, 1)
    my_first_list.clear()


f()
(base) saurabh-kumar@Awadh:~/Projects/System/lpython$ ./src/bin/lpython ./examples/example.py --show-python
def __main__global_stmts():
    my_first_list = [1, 2, 3, 4, 5]
    print(my_first_list)
    my_first_list.append(4)
    my_first_list.remove(2)
    print(my_first_list.count(4))
    my_first_list.insert(0, 1)
    my_first_list.clear()
    f()
def f():
    my_first_list: list[i32]
    my_first_list = [1, 2, 3, 4, 5]
    print(my_first_list)
    my_first_list.append(4)
    my_first_list.remove(2)
    print(my_first_list.count(4))
    my_first_list.insert(0, 1)
    my_first_list.clear()

@kmr-srbh
Copy link
Contributor Author

@Shaikh-Ubaid could you please look into the anomaly occurring in the generated code when a function call is present inside a function, as in, print(my_first_list.count(4))?

@ubaidsk ubaidsk marked this pull request as draft May 11, 2024 05:37
@kmr-srbh kmr-srbh marked this pull request as ready for review May 11, 2024 16:14
@kmr-srbh kmr-srbh requested a review from ubaidsk May 11, 2024 16:14
Copy link
Collaborator

@ubaidsk ubaidsk left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@ubaidsk ubaidsk merged commit 5452ed1 into lcompilers:main May 11, 2024
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.

2 participants